Skip to content
Rahul Shishodiaon GitHub LinkedIn profile

Troubleshooting Tips

Namespace and context

MistakeFast check
Wrong cluster contextkubectl config current-context
Resource created in wrong namespacekubectl get <resource> -A
Service in one namespace, Pods in anotherServices only select same-namespace Pods
kubectl config use-context <context>
kubectl config set-context --current --namespace=<ns>
kubectl get all -n <ns>

Labels and selectors

SymptomCause
Service has 0 EndpointsService selector does not match Pod labels
Only some Pods receive trafficOnly some Pods match selector
Deployment creates no PodsImmutable selector mismatch
kubectl get svc <svc> -o jsonpath='{.spec.selector}'
kubectl get po --show-labels
kubectl get endpoints <svc>

RBAC

MistakeFix
Bound a missing ServiceAccountCreate SA first
RoleBinding in wrong namespaceRoleBinding must be in Role namespace
Missing app API groupDeployments need apiGroups: [apps]
Needs logs/execAdd pods/log or pods/exec
kubectl auth can-i <verb> <resource> \
  --as=system:serviceaccount:<ns>:<sa> \
  -n <ns>

Ports

FieldMeaning
containerPortApp port inside Pod
Service targetPortPort on selected Pods
Service portPort clients use for Service
Ingress backend portService port, not targetPort

Probes

  • Liveness failure restarts containers
  • Readiness failure removes Pod from Service Endpoints
  • Aggressive liveness probes cause CrashLoopBackOff
  • Wrong readiness path can make a healthy app receive no traffic

ConfigMaps and Secrets

SymptomCause
CreateContainerConfigErrorMissing ConfigMap/Secret/key
File missing in mounted pathWrong mountPath, missing subPath, or key name mismatch
Env var absentenvFrom / secretKeyRef points to wrong object/key

NetworkPolicy

  • Default is allow until a policy selects Pods
  • podSelector: {} selects all Pods
  • Empty ingress: [] denies all ingress for selected Pods
  • Egress default-deny breaks DNS unless UDP/TCP 53 is allowed
  • Multiple from entries are OR; multiple selectors in one entry are AND

Storage

SymptomCheck
PVC Pendingkubectl describe pvc, StorageClass name
Mount failurePVC bound? claimName correct?
StatefulSet data remainsPVCs are not deleted with StatefulSet

Commands that save time

kubectl describe pod <pod>
kubectl logs <pod> --previous
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl label pod <pod> key=value --overwrite
kubectl get <resource> -o yaml

Final checklist

  • Practiced SA → Role → RoleBinding 5x
  • Can fix Service 0 Endpoints in under 2 min
  • Know port vs targetPort vs Ingress backend port
  • Can create a CronJob and trigger it with --from=cronjob
  • Can explain NetworkPolicy selector logic
  • Can debug ImagePullBackOff, CrashLoopBackOff, and CreateContainerConfigError