k8s | aks debug

A strict, ordered checklist for debugging Kubernetes on AKS: context, namespace, pods, services, ingress and logs.

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.
Where each check looks · numbers are sections belowABC1234CLUSTER · 1.0 2.0NAMESPACE · 3.0clientapi.example.comingress7.0 · 8.002service6.003endpoints6.004pod4.0 · 5.005localhostport-forward 9.0bypasses ingress
FIG. 1Where each check looks · numbers are sections below

Check which cluster you are connected to

Show current context:

spec · bash
kubectl config current-context

List all contexts:

spec · bash
kubectl config get-contexts

Switch to another cluster/context:

spec · bash
kubectl config use-context <context-name>

Connect to an AKS cluster (if context does not exist)

Check current subscription:

spec · bash
az account show

Switch subscription:

spec · bash
az account set --subscription "<subscription-id-or-name>"

Download cluster credentials:

spec · bash
az aks get-credentials \
  -g <resource-group> \
  -n <cluster-name> \
  --overwrite-existing

Work with namespaces

List namespaces:

spec · bash
kubectl get ns

List pods in a namespace:

spec · bash
kubectl get pods -n <namespace>

Tip: If you always work in a specific namespace, set it on the current context:

spec · bash
kubectl config set-context --current --namespace=<namespace>

Inspect pods

List pods:

spec · bash
kubectl get pods -n <namespace>

Describe a pod:

spec · bash
kubectl describe pod <pod-name> -n <namespace>

View logs

Stream logs from a pod:

spec · bash
kubectl logs -f <pod-name> -n <namespace>

Stream logs from a deployment:

spec · bash
kubectl logs -f deployment/<deployment-name> -n <namespace>

If a pod has multiple containers:

spec · bash
kubectl logs -f <pod-name> -c <container-name> -n <namespace>

Check services

List services:

spec · bash
kubectl get svc -n <namespace>

Check endpoints (which pods a service points to):

spec · bash
kubectl get endpoints -n <namespace>

Check ingress rules (important for APIs)

List ingress:

spec · bash
kubectl get ingress -n <namespace>

Show ingress routing details:

spec · bash
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:

spec · bash
kubectl logs -f <ingress-pod-name> -n <namespace>

Test a backend directly (very useful)

Forward a port from a pod:

spec · bash
kubectl port-forward pod/<pod-name> <local-port>:<container-port> -n <namespace>

Then test locally:

spec · bash
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:

  1. Am I connected to the correct cluster?
  2. Am I using the correct namespace?
  3. Is the pod in Running state?
  4. Does the service point to the pod?
  5. Does ingress have the correct path?
  6. Does the request reach ingress?
  7. 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.