Troubleshooting Kubernetes LoadBalancer Service Issues with kubectl
- Rajamohan Rajendran
- 5 days ago
- 2 min read
In Kubernetes, the LoadBalancer service type is widely used to expose applications externally using a cloud provider’s load balancer (like Azure, AWS, or GCP). However, there are times when the service gets stuck in a Pending or Terminating state, and the external IP never gets assigned — or the deletion never completes.
In this blog, we’ll walk through essential kubectl commands to help you diagnose and resolve these issues effectively.
Symptoms
EXTERNAL-IP remains in Pending status
Deleting the service hangs in Terminating
The cloud load balancer is not created or deleted properly
Stale finalizers prevent service deletion
Step-by-Step Troubleshooting with kubectl
1. Check the Service Status
kubectl get svc <your-service-name> -n <namespace>
2.Look for EXTERNAL-IP. If it shows:
<none> or pending
It means the cloud controller hasn’t provisioned the load balancer.
3.Describe the Service
kubectl describe svc <your-service-name> -n <namespace>
Look for:
• Events at the bottom
• Annotations like service.beta.kubernetes.io/* (incorrect ones may cause failure)
• Errors like:
• "Error syncing load balancer"
• "Unable to allocate IP"
4.Check for Finalizers (If Deleting is Stuck)
When a service is stuck in “Terminating,” it’s likely due to finalizers.
kubectl get svc <your-service-name> -n <namespace> -o json | jq .metadata.finalizers
To remove finalizers manually ( use carefully)
kubectl patch svc <your-service-name> -n <namespace> -p '{"metadata":{"finalizers":null}}' --type=merge
5.Ensure the Cloud Controller is Running
Check the logs for your cloud controller manager (varies by cloud).
kubectl get pods -n kube-system
kubectl logs <cloud-controller-pod> -n kube-system
6.Inspect Related Resources
In cloud-managed environments, sometimes an underlying cloud resource is stuck:
For Azure:
Check Azure Load Balancer in the Portal
Make sure subnet/deployment has enough IPs
recreate the service
Conclusion
A stuck LoadBalancer service in Kubernetes can block deployments and impact availability. Thankfully, kubectl provides all the necessary tooling to inspect, diagnose, and resolve these issues.
By following these steps and understanding the underlying cloud-provider integration, you can efficiently handle issues with LoadBalancer services and keep your Kubernetes workloads running smoothly.
Comments