Common Kubernetes Issues
A comprehensive guide to common Kubernetes issues covering resource exhaustion, DNS issues, certificate expiration, scheduler problems, and practical solutions for production clusters.
Kubernetes clusters encounter a range of issues in production. Understanding the most common problems and their solutions is essential for maintaining cluster health.
This guide covers the most frequently encountered issues:
- Resource Exhaustion: CPU, memory, disk, and pod limits
- DNS Issues: CoreDNS failures, resolution problems
- Certificate Expiration: TLS certificate management
- Scheduler Problems: Pod scheduling failures
- Node Issues: Node not ready, resource pressure
- Networking Issues: CNI, network policies, service connectivity
- Monitor cluster health proactively
- Set up alerts for resource thresholds
- Regularly renew certificates
- Test DNS resolution regularly
- Implement proper resource requests and limits
Resource exhaustion occurs when cluster resources (CPU, memory, disk, pods) are fully utilized, leading to performance degradation, pod evictions, and cluster instability.
Memory Exhaustion
CPU Exhaustion
Disk Exhaustion
Pod Exhaustion
# Diagnostic commands for Resource Exhaustion
# Check node resource usage
kubectl top nodes
# Check pod resource usage
kubectl top pods --all-namespaces
# Check node conditions
kubectl describe node <node-name> | grep -A 5 "Conditions"
# Check disk usage on node
df -h
du -sh /var/lib/containerd
# Check pod limits per node
kubectl describe node <node-name> | grep -A 10 "Allocated resources"
# Check for pod evictions
kubectl get events --field-selector reason=Evicted
# Check node capacity
kubectl describe node <node-name> | grep -A 10 "Capacity"
# Monitor memory usage over time
kubectl top pods --all-namespaces --sort-by=memory
# Monitor CPU usage over time
kubectl top pods --all-namespaces --sort-by=cpu
# Check resource quotas
kubectl get resourcequotas --all-namespaces
# Clean up unused images
crictl images | grep -v "latest" | awk '{print $3}' | xargs -r crictl rmi
docker system prune -f
- Set appropriate resource requests and limits
- Implement Horizontal Pod Autoscaling (HPA)
- Use Cluster Autoscaler for node scaling
- Regularly prune unused images and resources
- Monitor resource usage trends
- Implement resource quotas per namespace
DNS is critical for service discovery in Kubernetes. DNS issues can cause service failures, application errors, and cluster instability.
CoreDNS Failures
DNS Resolution Issues
DNS Timeouts
DNS Configuration Issues
# Diagnostic commands for DNS Issues
# Check CoreDNS pods
kubectl get pods -n kube-system -l k8s-app=kube-dns
# Check CoreDNS logs
kubectl logs -n kube-system -l k8s-app=kube-dns
# Check CoreDNS config
kubectl describe configmap coredns -n kube-system
# Test DNS resolution from pod
kubectl run test-pod --image=busybox -it --rm -- nslookup kubernetes.default.svc.cluster.local
# Check pod's resolv.conf
kubectl exec -it <pod-name> -- cat /etc/resolv.conf
# Check DNS service endpoints
kubectl get endpoints -n kube-system kube-dns
# Check CoreDNS metrics
kubectl port-forward -n kube-system svc/kube-dns 9153:9153
curl http://localhost:9153/metrics | grep coredns
# Restart CoreDNS
kubectl delete pods -n kube-system -l k8s-app=kube-dns
# Scale CoreDNS
kubectl scale deployment coredns -n kube-system --replicas=3
- Run at least 2 CoreDNS replicas for HA
- Set appropriate resource requests/limits for CoreDNS
- Monitor CoreDNS metrics and logs
- Configure DNS caching for performance
- Test DNS resolution after cluster upgrades
Kubernetes uses TLS certificates for secure communication between components. Expired certificates can cause cluster failures and API server unavailability.
API Server Certificate Expired
etcd Certificate Expired
Kubelet Certificate Expired
Service Account Certificate Expired
# Diagnostic commands for Certificate Issues
# Check certificate expiration (kubeadm)
kubeadm certs check-expiration
# Check API server certificate
openssl x509 -in /etc/kubernetes/pki/apiserver.crt -text -noout
# Check etcd certificate
openssl x509 -in /etc/kubernetes/pki/etcd/server.crt -text -noout
# Check kubelet certificate
openssl x509 -in /var/lib/kubelet/pki/kubelet-client-current.pem -text -noout
# Renew certificates (kubeadm)
kubeadm certs renew all
# Renew specific certificate
kubeadm certs renew apiserver
# Restart control plane components after renewal
kubectl delete pod -n kube-system kube-apiserver-<node>
kubectl delete pod -n kube-system kube-scheduler-<node>
kubectl delete pod -n kube-system kube-controller-manager-<node>
# Check service account token
kubectl describe secret <secret-name>
# Regenerate service account token
kubectl delete secret <secret-name>
# Monitor certificate expiration
kubeadm certs check-expiration --config /etc/kubernetes/kubeadm-config.yaml
- Regularly check certificate expiration
- Set up monitoring for certificate expiration
- Automate certificate renewal (kubeadm auto-renewal)
- Test certificate renewal in staging
- Keep backup of certificates
- Document certificate management procedures
The scheduler is responsible for assigning pods to nodes. Scheduler problems can cause pending pods and cluster imbalance.
Insufficient Resources
Node Affinity/Selector Issues
Taint/Toleration Issues
Pod Limit Reached
# Diagnostic commands for Scheduler Issues
# Check pending pods
kubectl get pods --field-selector status.phase=Pending
# Describe pending pod for reason
kubectl describe pod <pod-name>
# Check node resources
kubectl describe nodes
# Check node labels
kubectl get nodes --show-labels
# Check node taints
kubectl describe nodes | grep Taints
# Check scheduler logs
kubectl logs -n kube-system kube-scheduler-<node>
# Check scheduler events
kubectl get events --field-selector involvedObject.kind=Pod
# Check pod scheduling conditions
kubectl get pods -o wide | grep Pending
# Check node pod count
kubectl get nodes -o json | jq '.items[].status.allocatable.pods'
# Check cluster autoscaler
kubectl get pods -n kube-system -l app=cluster-autoscaler
# Add node label
kubectl label nodes <node-name> node-type=app
- Check pending pod description for scheduling failure reasons
- Monitor node resource usage and availability
- Review scheduler logs for error messages
- Check cluster autoscaler if nodes are insufficient
- Verify nodeSelector and affinity rules
# Resource Exhaustion
kubectl top nodes
kubectl top pods --all-namespaces
kubectl describe node <node>
# Solutions: Add nodes, reduce requests, prune images
# DNS Issues
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system coredns-<pod>
kubectl run test --image=busybox --rm -it -- nslookup kubernetes.default.svc
# Solutions: Restart CoreDNS, scale, check config
# Certificate Expiration
kubeadm certs check-expiration
kubeadm certs renew all
# Solutions: Renew certificates, restart components
# Scheduler Problems
kubectl get pods --field-selector status.phase=Pending
kubectl describe pod <pod>
kubectl describe nodes
# Solutions: Add resources, update affinities, add tolerations
# Node Issues
kubectl get nodes
kubectl describe node <node>
journalctl -u kubelet -f
# Solutions: Restart kubelet, free resources, replace node
# Networking Issues
kubectl get pods -n kube-system -l k8s-app=calico-node
kubectl get endpoints --all-namespaces
kubectl get networkpolicies --all-namespaces
# Solutions: Check CNI, verify policies, restart components
kubectl describe pod for the specific reason.Understanding common Kubernetes issues and their solutions is essential for maintaining production clusters. Implement proactive monitoring, regular maintenance, and automated responses to minimize downtime.