STEP 3: SETTING UP AKS STEP-BY-STEP
Source: Dev.to
Prerequisites
az version
az login
Step 1: Create AKS Cluster
az aks create \
--resource-group devops-rg \
--name myAKSCluster \
--node-count 2 \
--enable-addons monitoring \
--generate-ssh-keys
Step 2: Connect AKS to ACR
az aks update \
--resource-group devops-rg \
--name myAKSCluster \
--attach-acr
Step 3: Get AKS Credentials for kubectl
az aks get-credentials \
--resource-group devops-rg \
--name myAKSCluster
Step 4: Verify Connection
kubectl get nodes
Step 5: Verify Namespaces
kubectl get namespaces
Step 6 (Optional): Enable Autoscaling
az aks update \
--resource-group devops-rg \
--name myAKSCluster \
--enable-cluster-autoscaler \
--min-count 1 \
--max-count 5
Step 7: Create Deployment
kubectl create deployment myapp --image=myapp
Step 8: Update & Restart the Deployment Image
Edit the deployment to use your ACR login server image, e.g.:
# In the deployment spec, set:
image: .azurecr.io/myapp:latest
Then restart the deployment:
kubectl rollout restart deployment myapp
Check the pods:
kubectl get pods
Step 9: Expose Deployment
kubectl expose deployment myapp \
--port=80 \
--target-port=3000 \
--type=LoadBalancer
Step 10: Get Services
kubectl get service myapp
Step 11: Test in Browser
Open a web browser and navigate to the external IP address of the myapp service.