How to provision an Azure AKS cluster and deploy a workload
AKS is Azure-managed Kubernetes created with a few az aks commands. Get credentials for kubectl, deploy and expose a workload via a public load balancer, and enable the cluster autoscaler for elasticity.
Provisioning an Azure AKS cluster
Azure Kubernetes Service (AKS) is Microsoft's managed Kubernetes. Azure operates the control plane at no charge; you pay for the worker nodes. The Azure CLI creates a cluster in a couple of commands and wires up monitoring and identity.
Prerequisites
- An Azure subscription with permission to create resources.
- The Azure CLI (
az) andkubectlinstalled.
Steps
1. Sign in and set subscription
az login
az account set --subscription "<subscription-id>"
2. Create a resource group
az group create --name demo-rg --location eastus
3. Create the AKS cluster
az aks create \
--resource-group demo-rg \
--name demo-aks \
--node-count 3 \
--enable-managed-identity \
--generate-ssh-keys
Provisioning takes several minutes.
4. Get cluster credentials
az aks get-credentials --resource-group demo-rg --name demo-aks
kubectl get nodes
5. Deploy a workload
kubectl create deployment web --image=nginx --replicas=3
kubectl expose deployment web --port=80 --type=LoadBalancer
kubectl get svc web --watch
Azure provisions a public load balancer with an external IP.
6. Enable the cluster autoscaler
az aks update \
--resource-group demo-rg --name demo-aks \
--enable-cluster-autoscaler --min-count 2 --max-count 6
Verification
Confirm nodes are Ready and pods Running. Browse to the load balancer's external IP and confirm the app responds. In the Azure portal, confirm the AKS resource and node pool report healthy.
Next Steps
Integrate Microsoft Entra ID for RBAC, use workload identity for pod access to Azure resources, attach Azure Container Registry for image pulls, and enable Azure Monitor for containers. Codify the cluster in Bicep or Terraform, and run az group delete --name demo-rg to clean up.
Prerequisites
- An Azure subscription
- Azure CLI installed
- kubectl installed
Steps
- 1Sign in and set subscription
- 2Create a resource group
- 3Create the AKS cluster
- 4Get cluster credentials
- 5Deploy a workload
- 6Enable the cluster autoscaler