Deploy a Kubernetes cluster with Azure AKS
Prerequisites
- An Azure subscription (free trial works).
- Azure CLI installed –
azversion 2.30+ - kubectl installed – version 1.23+
- Git installed.
Log in to Azure:
az login
1. Create a Resource Group
Choose a name and region:
az group create --name myResourceGroup --location eastus
2. Create an AKS Cluster
Run the following command to provision a basic cluster with two nodes:
az aks create --resource-group myResourceGroup --name myAKSCluster --node-count 2 --enable-addons monitoring --generate-ssh-keys
Get credentials for kubectl:
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
Verify the cluster is reachable:
kubectl get nodes
3. Deploy a Sample Application
Clone the sample repo:
git clone https://github.com/Azure-Samples/azure-voting-app-redis.git
Deploy the manifests:
kubectl apply -f azure-voting-app-redis/azure-vote-all-in-one-redis.yaml
Expose the service:
kubectl expose deployment azure-vote-front --type=LoadBalancer --name=azure-vote-front-lb
Retrieve the external IP (may take a minute):
kubectl get service azure-vote-front-lb --watch
Open the IP address in a browser to see the voting app.
4. Cleanup Resources
When you're done, delete the resource group to avoid charges:
az group delete --name myResourceGroup --yes --no-wait