While working with Kubernetes on OKE (Oracle Kubernets Engine), I encountered many issues, so I decided to create a troubleshooting guide to help identify and resolve common problems in Kubernetes deployments. πππ
- Pod issues (e.g., CrashLoopBackOff, ImagePullBackOff)
- Service misconfigurations
- Ingress connectivity problems
Kubernetes deployments can encounter various issues ranging from pod scheduling problems to service misconfigurations. This guide provides a systematic approach to: πππ
- Identify the root cause of issues.
- Apply appropriate fixes.
- Ensure a smooth deployment process.
- Step-by-Step Troubleshooting Instructions: Navigate problems systematically.
- Command Examples: Useful Kubernetes CLI commands.
- Introduction
- Troubleshooting Pods
- Troubleshooting Services
- Troubleshooting Ingress
- General Debugging Commands
- Run: π³π³π³
kubectl get pods
- Observe the pod's status:
- PENDING: Move to Step 2.
- CrashLoopBackOff: See Step 3.
- ImagePullBackOff: Refer to Step 4.
-
verify if the cluster has sufficient resources: βοΈβοΈβοΈ
kubectl describe pod <pod-name>
-
If resources are insufficient:
- Scale up the cluster.
- Relax ResourceQuota limits if applicable.
-
Check logs: π οΈπ οΈπ οΈ
kubectl logs <pod-name> --previous
-
Common fixes:
- Update Dockerfile to include CMD if missing.
- Fix readiness or liveness probes if they are failing.
-
Verify the image name and tag: πΌοΈπΌοΈπΌοΈ
kubectl describe pod <pod-name>
-
Common solutions:
- Correct image name/tag.
- Configure access to private registries if required.
-
Check if the service exposes the correct port: π§©π§©π§©
kubectl describe service <service-name>
-
Ensure targetPort matches the container's containerPort.
- Verify endpoints: π‘π‘π‘ ```kubectl get endpoints``
- If no endpoints are listed:
- Check if the service selector matches pod labels.
- Inspect pod readiness.
- Forward a service port to localhost: πππ
kubectl port-forward service/<service-name> 8080:<service-port>
- Verify the app's accessibility at http://localhost:8080.
- Describe ingress: π£οΈπ£οΈπ£οΈ
kubectl describe ingress <ingress-name>
- Check serviceName and servicePort mappings.
- Ensure backends are listed: π―π―π―
kubectl get endpoints
- If backends are missing:
- Fix service configuration.
- Verify pod readiness and labels.
- Forward ingress port to localhost: πππ
kubectl port-forward <ingress-pod-name> 8080:<ingress-port>
- Test access at http://localhost:8080.
-
Current logs: πππ
kubectl logs <pod-name>
-
Previous logs: πππ
kubectl logs <pod-name> --previous
-
Pod details: πππ
kubectl describe pod <pod-name>
-
Service details: π οΈπ οΈπ οΈ
kubectl describe service <service-name>
-
Ingress details: πππ
kubectl describe ingress <ingress-name>
We welcome contributions! Please open an issue or submit a pull request to help improve this guide.