Summary - Troubleshooting
- Docker & Kubernetes course
- Intermediate
- Lesson 77/82
- 5 min
Combine logs, exec and describe to solve a Pod issue.
Summary: troubleshooting
The troubleshooting order:
kubectl get pods: what do STATUS and RESTARTS say?kubectl describe pod: the Events section (image, scheduling, mounts, probes).kubectl logs(--previous,-c,-l): the application's own error message.kubectl exec/debug: environment, DNS, connectivity from inside.- 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/SecretPractice 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
# buraya yazSample solution
kubectl get svc web -o jsonpath='{.spec.selector}'
kubectl get pods --show-labels
kubectl get endpointslices -l kubernetes.io/service-name=webExpected 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.
kubectl ____ pod api-xyz
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 |