Top 10 Common Kubernetes Issues and How to Fix Them
This guide walks through ten frequent Kubernetes problems—from service access failures and port‑mapping errors to image pull issues and CrashLoopBackOff—explaining root causes, showing exact error messages, and providing concise command‑line solutions to restore cluster health.
Problem 1: Kubernetes service access failure (certificate issue)
Cause analysis: The certificate is unrecognised, often due to a custom or expired certificate.
Solution: Update the certificate.
Problem 2: Kubernetes service access failure (port‑mapping error)
Example error:
curl: (7) Failed connect to 10.103.22.158:3000; Connection refusedCause analysis: Port mapping is incorrect; the service runs but cannot be reached.
Solution: Delete the Service and recreate it with the correct port mapping.
kubectl delete svc nginx-deploymentProblem 3: Service exposure failure (service already exists)
Example error:
Error from server (AlreadyExists): services "nginx-deployment" already existsCause analysis: The service has already been created.
Solution: Delete the existing Service and recreate it with the proper port mapping.
Problem 4‑1: External access to a ClusterIP service is blocked
Cause analysis: The Service type is ClusterIP, which does not expose the service outside the cluster.
Solution: Change the Service type to NodePort so it can be accessed via any cluster node.
kubectl edit svc nginx-deploymentProblem 4‑2: Pod stuck in ErrImagePull
Cause analysis: The container image cannot be pulled.
Solution: Replace the image with a valid one.
Problem 5: Init container remains in an abnormal state
Observed pod status:
NAME READY STATUS RESTARTS AGE
myapp-pod 0/1 Init:0/2 0 20sCause analysis: The init container never finishes, preventing the main container from starting.
Additional error:
Error from server (BadRequest): container "myapp-container" in pod "myapp-pod" is waiting to start: PodInitializingSolution: Ensure the init container completes successfully, often by fixing the image.
Problem 6: DNS resolution failure during init container execution
CoreDNS cannot resolve the service name, producing NXDOMAIN errors.
Solution: Create the required Service and add its name to CoreDNS so that DNS queries succeed.
kubectl apply -f myservice.yamlProblem 7: Pod repeatedly crashes (CrashLoopBackOff)
Cause analysis: The container image is faulty, causing the container to restart continuously.
Solution: Replace the problematic image with a working one.
Problem 8: Pod creation fails with various states (Pending, Error, CrashLoopBackOff)
Observed status progression:
readiness-httpget-pod 0/1 Pending 0 0s
...
readiness-httpget-pod 0/1 CrashLoopBackOff 4 82sCause analysis: Image problems prevent the container from starting.
Solution: Use a correct, pullable image.
Problem 9: Pod never reaches Ready state
Observed status: readiness-httpget-pod 0/1 Running 0 116s Cause analysis: The pod’s command fails, so required resources are not obtained.
Solution: Exec into the container and create the resources defined in the pod’s YAML.
Problem 10: Pod creation fails due to malformed YAML (Chinese characters)
Cause analysis: The YAML file contains invalid Chinese characters.
Solution: Edit the myregistrykey content to remove the illegal characters.
These troubleshooting steps, combined with the shown kubectl commands and error outputs, provide a practical reference for diagnosing and resolving common Kubernetes deployment issues.
Full-Stack DevOps & Kubernetes
Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
