CodeBlanks Logo Icon CodeBlanks

Summary - Troubleshooting

Combine logs, exec and describe to solve a Pod issue.

Summary: troubleshooting

The troubleshooting order:

  1. kubectl get pods: what do STATUS and RESTARTS say?
  2. kubectl describe pod: the Events section (image, scheduling, mounts, probes).
  3. kubectl logs (--previous, -c, -l): the application's own error message.
  4. kubectl exec / debug: environment, DNS, connectivity from inside.
  5. For service problems: is the EndpointSlice empty, does the selector match?
ImagePullBackOff   -> image name / imagePullSecrets
CrashLoopBackOff   -> logs --previous, exit code
Pending            -> describe: FailedScheduling
CreateContainerConfigError -> missing ConfigMap/Secret

Practice Debug the service

Write three commands: print the web service's selector with jsonpath='{.spec.selector}'; list the pods with their labels; list the EndpointSlices of the web service with -l kubernetes.io/service-name=web.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl get svc web -o jsonpath='{.spec.selector}'
kubectl get pods --show-labels
kubectl get endpointslices -l kubernetes.io/service-name=web

Expected output

{"app":"web-on"}
NAME                  READY   STATUS    LABELS
web-7c5b9f6d8-abcde   1/1     Running   app=web,pod-template-hash=7c5b9f6d8
NAME        ADDRESSTYPE   PORTS     ENDPOINTS
web-x7k2p   IPv4          <unset>   <unset>

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 The pod is Running and READY 1/1, but requests to the service address time out. What should be checked first?

  • The service's EndpointSlice and whether the selector matches the pod labels Correct answer
  • The image version
  • The node count
  • The kubeconfig file

Explanation: If the pod is healthy, the problem is usually the link between service and pod (selector or targetPort).

2 Look at the pod's events first.

Question
kubectl ____ pod api-xyz
Answer
kubectl describe pod api-xyz

Explanation: describe pod includes the Events section.

3 Match the symptoms.

Term Meaning
ImagePullBackOff Image problem
CrashLoopBackOff The app crashes
Pending Couldn't be placed
CreateContainerConfigError Missing config object

All lessons in Intermediate