Create and Manage an AKS Kubernetes Cluster
Advanced20 minTrending
Provision a fully managed Kubernetes cluster on Azure Kubernetes Service, connect kubectl, and deploy a workload.
Prerequisites
- -Azure CLI installed
- -Active Azure subscription
- -kubectl installed
- -Basic Kubernetes knowledge
Steps
1
Create a resource group
Create a dedicated resource group for the AKS cluster.
$ az group create --name aks-rg --location eastus
2
Create the AKS cluster
Provisions a two-node cluster with managed identity authentication.
$ az aks create --resource-group aks-rg --name myaks --node-count 2 --node-vm-size Standard_B2s --generate-ssh-keys --enable-managed-identity
Standard_B2s is cost-effective for dev/test. Use Standard_D4s_v5 or larger for production.
Cluster creation takes 5-10 minutes. Do not interrupt the command.
3
Get cluster credentials
Downloads the kubeconfig and merges it into your local kubectl context.
$ az aks get-credentials --resource-group aks-rg --name myaks
4
Verify connectivity
Confirms kubectl can reach the cluster and shows the node status.
$ kubectl get nodes
5
Deploy a sample workload
Deploys an nginx pod with two replicas and exposes it via an Azure Load Balancer.
$ kubectl create deployment nginx --image=nginx:latest --replicas=2 && kubectl expose deployment nginx --port=80 --type=LoadBalancer
6
Scale the cluster
Adds another node to the cluster to handle increased load.
$ az aks scale --resource-group aks-rg --name myaks --node-count 3
Full Script
FAQ
Discussion
Loading comments...