k8s | aks debug
A strict, ordered checklist for debugging Kubernetes on AKS: context, namespace, pods, services, ingress and logs.
4 min readkubernetes · aks · debugging · devops
This is a fast, practical cheat sheet for debugging basics in Kubernetes and AKS. It includes core concepts plus a strict, ordered flow to isolate issues quickly.
Quick Concepts (Cluster, Namespace, Pod, Service, Ingress)
- Cluster: The full Kubernetes environment. Think of it as the logical “datacenter” where all resources live. In AKS, each cluster is its own managed control plane.
- Namespace: A logical partition inside a cluster. Use it to separate environments (dev, qa, prod), teams, or apps. A single cluster can host multiple namespaces.
- Pod: The smallest execution unit. A pod can run one or more containers that deploy and scale together.
- Deployment: Manages pod replicas and rolling updates. If a pod dies, the deployment creates a new one.
- Service: Exposes a stable endpoint for a set of pods and load‑balances traffic to them.
- Ingress: HTTP/HTTPS routing rules. Maps domains and paths to services.
Check which cluster you are connected to
Show current context:
kubectl config current-contextList all contexts:
kubectl config get-contextsSwitch to another cluster/context:
kubectl config use-context <context-name>Connect to an AKS cluster (if context does not exist)
Check current subscription:
az account showSwitch subscription:
az account set --subscription "<subscription-id-or-name>"Download cluster credentials:
az aks get-credentials \
-g <resource-group> \
-n <cluster-name> \
--overwrite-existingWork with namespaces
List namespaces:
kubectl get nsList pods in a namespace:
kubectl get pods -n <namespace>Tip: If you always work in a specific namespace, set it on the current context:
kubectl config set-context --current --namespace=<namespace>Inspect pods
List pods:
kubectl get pods -n <namespace>Describe a pod:
kubectl describe pod <pod-name> -n <namespace>View logs
Stream logs from a pod:
kubectl logs -f <pod-name> -n <namespace>Stream logs from a deployment:
kubectl logs -f deployment/<deployment-name> -n <namespace>If a pod has multiple containers:
kubectl logs -f <pod-name> -c <container-name> -n <namespace>Check services
List services:
kubectl get svc -n <namespace>Check endpoints (which pods a service points to):
kubectl get endpoints -n <namespace>Check ingress rules (important for APIs)
List ingress:
kubectl get ingress -n <namespace>Show ingress routing details:
kubectl describe ingress -n <namespace>Look for:
- Paths
- Backend services
- Rewrite rules
These determine the real API URLs.
View ingress controller logs
Useful when requests are not reaching the backend:
kubectl logs -f <ingress-pod-name> -n <namespace>Test a backend directly (very useful)
Forward a port from a pod:
kubectl port-forward pod/<pod-name> <local-port>:<container-port> -n <namespace>Then test locally:
curl http://127.0.0.1:<local-port>This bypasses ingress and networking issues.
Quick troubleshooting checklist
When something is not working, debug in this order:
- Am I connected to the correct cluster?
- Am I using the correct namespace?
- Is the pod in
Runningstate? - Does the service point to the pod?
- Does ingress have the correct path?
- Does the request reach ingress?
- Does the request reach the backend?
Quick rule for debugging requests
If no logs appear:
- Not in ingress logs → request never reached the cluster.
- In ingress logs but not backend → routing issue.
- In backend logs → application issue.
This helps isolate problems quickly.