Kubernetes is a powerful platform for deploying and managing containerized applications, but even experienced teams face challenges when dealing with Pods, Deployments, and Services. Whether you’re running an eCommerce platform, SaaS application, financial services software, or an AI-powered analytics tool, ensuring smooth deployment and availability is crucial.
In this guide, we’ll walk through a real-world troubleshooting approach to fixing common Kubernetes issues, helping you keep your application running efficiently.
Imagine your team is deploying a cloud-native application with the following setup:
However, the team encounters three major issues:
To fix these, we will take a systematic troubleshooting approach and ensure that the application remains stable and performant.
Before troubleshooting, let’s verify the cluster setup and ensure the correct namespace is used.
kubectl cluster-info
kubectl get nodes
Ensure that all nodes are in a Ready state.
kubectl create namespace my-application
kubectl config set-context --current --namespace=my-application
Navigate to the directory where Kubernetes manifests are stored:
ls manifests/
Ensure that deployments.yaml and service.yaml exist.
Problem: The Pods aren’t starting, and kubectl get pods shows ImagePullBackOff or ErrImagePull.
kubectl get pods -n my-application
If you see ImagePullBackOff, it indicates an issue with the container image.
kubectl describe deployment <deployment-name> -n my-application
Look for errors like:
docker pull <image-name>:<tag>
If the image doesn’t exist, update your deployments.yaml file:
containers:
- name: my-app
image: correct-registry/my-app:latest
kubectl apply -f manifests/deployments.yaml -n my-application
Restart the Pods if necessary:
kubectl rollout restart deployment <deployment-name> -n my-application
Problem: The Service is running, but the app is not accessible.
kubectl get svc -n my-application
kubectl describe service <service-name> -n my-application
Look for mismatched port configurations.
service.yamlports:
- port: 80
targetPort: 8080
Ensure targetPort matches the container’s containerPort.
kubectl get endpoints <service-name> -n my-application
If no endpoints are listed, it means no Pods are connected to the Service.
kubectl port-forward svc/<service-name> 8080:80 -n my-application
curl http://localhost:8080
kubectl rollout restart deployment <deployment-name> -n my-application
Problem: Deployment is running, but it’s struggling with high CPU/memory usage.
kubectl top pod -n my-application
kubectl describe deployment <deployment-name> -n my-application
Look for OOMKills (Out of Memory errors) or high CPU usage.
In deployments.yaml, add resource constraints:
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
kubectl apply -f manifests/deployments.yaml -n my-application
kubectl get pods -w -n my-application
kubectl scale deployment <deployment-name> --replicas=3 -n my-application
After applying fixes, check everything is working as expected.
kubectl get all -n my-application
kubectl logs -f <pod-name> -n my-application
kubectl port-forward svc/<service-name> 8080:80 -n my-application
curl http://localhost:8080
kubectl get pods -w -n my-application
✅ Check Pod & Deployment issues: Ensure container images are correctly specified and available.
✅ Validate Service configuration: Match ports, verify endpoints, and test connectivity.
✅ Monitor resource usage: Set proper CPU and memory limits to prevent failures.
✅ Use logs & events for insights: kubectl logs and kubectl describe provide crucial debugging info.
✅ Scale when needed: Use horizontal scaling (kubectl scale) to improve reliability.
By following these structured troubleshooting techniques, you can ensure your Kubernetes-based application runs smoothly, whether it’s an eCommerce store, a financial analytics tool, a content management system, or an AI-powered SaaS platform. 🚀
Ref : https://pineave-newsletter.beehiiv.com/p/troubleshooting-kubernetes-deployments-services-a-practical-guide