This project demonstrates how to deploy a Node.js app on Azure Kubernetes Service (AKS) and how to troubleshoot common container issues such as CrashLoopBackOff
, image pull failures, and service IP issues.
git clone https://github.com/Gurram2001/azure-aks-nodejs-trobleshoot.git
cd aks-nodejs-troubleshooting
- Azure CLI
- AKS (Azure Kubernetes Service)
- ACR (Azure Container Registry)
- Docker
- Node.js + Express
- Kubernetes YAMLs (Deployment + Service)
kubectl
# Set Variables
RG=aks-node-rg
AKS=aks-node-cluster
ACR=acraksdemo1234 #any unique name.
# Create Resource Group
az group create --name $RG --location eastus
# Create Azure Container Registry
az acr create --name $ACR --resource-group $RG --sku Basic --admin-enabled true
# Create AKS Cluster, Connect AKS to ACR
az aks create --resource-group $RG --name $AKS --node-count 2 --generate-ssh-keys --attach-acr $ACR --node-vm-size standard_d2_v5
# Get AKS Credentials
az aks get-credentials --resource-group $RG --name $AKS
In your app/ directory:
cd app
az acr login --name $ACR
docker build -t $ACR.azurecr.io/aks-nodejs-api:v1 .
docker push $ACR.azurecr.io/aks-nodejs-api:v1
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl get pods
kubectl get service nodejs-service
Cause: Missing or invalid environment variable (PORT
).
How to simulate:
# In deployment.yaml
env:
- name: PORT
value: ""
Fix:
env:
- name: PORT
value: "3000"
Check logs:
kubectl logs <pod-name>
Cause: Typo in image name or ACR not linked to AKS.
How to simulate:
image: acraksdemo1234.azurecr.io/fake-nodejs:v1
Fix:
image: acraksdemo1234.azurecr.io/aks-nodejs-api:v1
Describe pod for error:
kubectl describe pod <pod-name>
Cause: LoadBalancer may not be provisioned.
kubectl get svc
Fix: Use port-forward as fallback:
kubectl port-forward svc/nodejs-service 8080:80
Test app at: http://localhost:8080
Enable monitoring with Container Insights:
az aks enable-addons --addons monitoring --name $AKS --resource-group $RG
You now have:
- A working AKS cluster with Node.js app deployed
- Practical experience fixing
CrashLoopBackOff
, image errors, and networking issues - A reusable project for interviews and resume ``