Sub topic 7
Service types and what changes when debugging each
This chapter assumes you can read a Service's selector, ports, and EndpointSlices, as covered in the earlier chapters. The Service type decides how clients reach the Service. It does not change how the Service chooses Pods. Selector, port, and readiness problems look the same for every type. Each type adds extra places where traffic can fail.
The types build on each other
A NodePort Service also gets a cluster IP. A LoadBalancer Service also gets a node port and a cluster IP. So you can debug from the inside out: confirm the ClusterIP path works first, then test the layers added by the other types.
| Type | How clients reach it | Extra failure points |
|---|---|---|
| ClusterIP | Virtual IP and DNS name, inside the cluster only | None beyond selector, ports, and endpoints |
| NodePort | `<node IP>:<node port>`, usually 30000-32767 | Node firewall, security groups, `externalTrafficPolicy` |
| LoadBalancer | External IP from the cloud provider | Provisioning, health checks, cloud quotas |
| Headless | DNS only, no virtual IP | DNS returns Pod IPs directly, with no kube-proxy in the path |
ClusterIP
This is the default type and the one used in the earlier examples. Test it from a Pod inside the cluster. A request from your laptop will fail by design, because the cluster IP is not routable outside the cluster.
NodePort
If the ClusterIP works but the node port does not, the problem is between the client and the node. Check the assigned port, then test against a node address:
kubectl get service web-nodeport -o wide
kubectl get nodes -o wide
curl -m 5 http://<node-internal-or-external-ip>:<node-port>Common causes are a firewall or cloud security group that blocks the node port, and using a node IP the client cannot reach. Also look at externalTrafficPolicy. With Local, a node that has no ready Pod for the Service drops the traffic. A request to one node can then fail while a request to another succeeds.
LoadBalancer
An external IP of <pending> means the cloud controller has not provisioned the load balancer. Read the Events section for the reason:
kubectl get service web-lb
kubectl describe service web-lbTypical causes are missing cloud permissions, exhausted quotas, or a cluster with no load balancer integration. On bare metal you need an add-on that assigns external IPs. If the IP is assigned but requests time out, check the load balancer's health checks. They usually probe the node port, so the same node-level firewall rules apply.
Headless Services
Setting clusterIP: None creates a headless Service. It has no virtual IP, and DNS returns the IPs of the ready Pods directly.
apiVersion: v1
kind: Service
metadata:
name: web-headless
spec:
clusterIP: None
selector:
app: web
ports:
- port: 80Because no virtual IP exists, there is no kube-proxy rule to inspect. Check the DNS answer instead:
kubectl run tmp-debug --rm -it --restart=Never --image=busybox:1.36 -- nslookup web-headlessYou should see one A record per ready Pod. An empty answer means the Service has no ready endpoints. Clients choose among the returned IPs themselves, so a client that caches one address can keep using a Pod that was replaced.
Exercise
A NodePort Service works when you curl the ClusterIP from a debug Pod, but curling node 1 on the node port times out. What do you check next?
Show answer
The path between the client and the node. Confirm the node IP is reachable from the client, check firewall or security group rules for the node port, and check externalTrafficPolicy. If it is Local, node 1 may have no ready Pod for the Service. The selector and endpoints are already proven by the ClusterIP test.