DEV Community

Cover image for STEP 3: SETTING UP AKS STEP-BY-STEP
Adekunle Osatuyi
Adekunle Osatuyi

Posted on

STEP 3: SETTING UP AKS STEP-BY-STEP

Prerequisites
i. Azure CLI installed: az version
ii. Login Azure: az login
iii. Login to ACR: _az acr login --name

STEP 1: Create AKS Cluster
The command below will create a 2-node cluster (you can adjust as needed):
az aks create --resource-group devops-rg --name myAKSCluster --node-count 2 --enable-addons monitoring --generate-ssh-keys

STEP 2: Connecting AKS to ACR
This lets your cluster pull container images securely.
az aks update --resource-group devops-rg --name myAKSCluster --attach-acr

STEP 3: Get AKS Credentials for kubectl
This will download the kubeconfig locally.
az aks get-credentials --resource-group devops-rg --name myAKSCluster

STEP 4: Verify Connection
Check if kubectl can see your nodes:
kubectl get nodes

STEP 6: Verify Namespaces
It shows a default system namespaces:
kubectl get namespaces

STEP 7 (Optional): Enable Autoscaling
This enables automatic node scaling:
az aks update --resource-group devops-rg --name myAKSCluster --enable-cluster-autoscaler --min-count 1 --max-count 5

STEP 8: Create Deployment
kubectl create deployment myapp --image=myapp

STEP 9: Update &Restart the Deployment image
kubectl edit deployment myapp

N:B: Edit image: myapp with your ACR LOGIN SERVER i.e image: image: .azurecr.io/myapp:latest

kubectl rollout restart deployment myapp

Check pods
kubectl get pods

STEP 10: Expose deployment
kubectl expose deployment myapp --port=80 --target-port=3000 --type=LoadBalancer

STEP 11:* Get services
kubectl get service myapp

STEP 12: Test in browser
http://

Top comments (0)