Application Troubleshooting¶
Common application deployment and runtime issues.
ImagePullBackOff¶
Pod cannot pull container image.
# Check image and error
kubectl describe pod <pod> -n <namespace>
# Create image pull secret
kubectl create secret docker-registry regcred \
--docker-server=<registry> \
--docker-username=<username> \
--docker-password=<password> \
-n <namespace>
# Add to deployment
kubectl patch serviceaccount default -n <namespace> \
-p '{"imagePullSecrets":[{"name":"regcred"}]}'
CrashLoopBackOff¶
Pod repeatedly crashes.
# View logs
kubectl logs <pod> -n <namespace>
kubectl logs <pod> --previous -n <namespace>
# Check exit code and events
kubectl describe pod <pod> -n <namespace>
# Common fixes:
# - Increase memory limits
kubectl set resources deployment <name> --limits=memory=2Gi -n <namespace>
# - Check environment variables
kubectl get deployment <name> -n <namespace> -o jsonpath='{.spec.template.spec.containers[0].env}'
Pod Stuck Pending¶
Pod not scheduling.
# Check why pending
kubectl describe pod <pod> -n <namespace>
# Check node resources
kubectl top nodes
# Check PVC status if used
kubectl get pvc -n <namespace>
Service Not Accessible¶
Cannot reach service.
# Check service and endpoints
kubectl get svc,endpoints <service> -n <namespace>
# Verify pod labels match selector
kubectl get pods -n <namespace> --show-labels
kubectl get svc <service> -n <namespace> -o jsonpath='{.spec.selector}'
# Test from within cluster
kubectl run debug --rm -it --image=curlimages/curl -n <namespace> -- \
curl http://<service>.<namespace>.svc.cluster.local
Ingress Not Working¶
External access fails.
# Check ingress and controller
kubectl get ingress -n <namespace>
kubectl describe ingress <name> -n <namespace>
kubectl get pods -A | grep ingress
# Verify DNS
nslookup <hostname>
# Check backend service
kubectl get svc <backend> -n <namespace>
kubectl get endpoints <backend> -n <namespace>
# Test backend directly
kubectl port-forward svc/<backend> 8080:80 -n <namespace>
PVC Not Bound¶
Storage not binding.
# Check PVC and storage class
kubectl get pvc,storageclass -n <namespace>
kubectl describe pvc <pvc> -n <namespace>
# Set default storage class if needed
kubectl patch storageclass <name> \
-p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
Out of Memory¶
Pod killed due to memory.