Skip to main content

How to debug AKS pods

Start by identifying the pod state, then follow the appropriate debugging path:

# Follow logs for a specific pod
kubectl logs -n internal-platform <pod-name> -f

# Logs for all pods with a label
kubectl logs -n internal-platform -l app=astra-backend --tail=100

# Previous container logs (after crash)
kubectl logs -n internal-platform <pod-name> --previous

Common errors

Pod stuck in Pending

  • Check: kubectl describe pod -n <ns> <pod> — look for scheduling errors
  • Common cause: Insufficient resources on nodes

Pod in CrashLoopBackOff

  • Check: kubectl logs -n <ns> <pod> --previous — see crash output
  • Common cause: Missing environment variables or database connection failure

Pod in ImagePullBackOff

  • Check: kubectl describe pod -n <ns> <pod> — look for ACR auth errors
  • Fix: az acr login --name aucertacr41e0x5

Pod running but returning errors

# Live log stream
kubectl logs -n <ns> <pod-name> -f

# Check environment variables are set correctly
kubectl exec -n <ns> <pod-name> -- env | sort

# Check if the pod can reach dependent services
kubectl exec -n <ns> <pod-name> -- curl -s http://localhost:8080/health

Quick reference

CommandPurpose
kubectl get pods -n <ns>List pod status
kubectl describe pod -n <ns> <pod>Detailed pod info + events
kubectl logs -n <ns> <pod> -fStream live logs
kubectl logs -n <ns> <pod> --previousLogs from crashed container
kubectl exec -n <ns> -it <pod> -- /bin/shShell into pod
kubectl port-forward -n <ns> svc/<svc> <local>:<remote>Forward port
kubectl top pod -n <ns>CPU/memory usage

What's next