Kubernetes Services Explained: ClusterIP, NodePort, LoadBalancer and Headless
How Kubernetes Services give pods stable networking: selectors, endpoints, ClusterIP, NodePort, LoadBalancer, headless services, DNS names and debugging.
Published December 1, 2026
Pods come and go, and each new pod gets a new IP address. A Service gives a group of pods a stable virtual IP and DNS name, and load-balances traffic across whichever pods are currently ready. Choosing the right Service type determines whether your app is reachable only inside the cluster, from the nodes, or from the internet.
The concept
A Service selects pods by labels. Kubernetes tracks the matching ready pods in EndpointSlices, and kube-proxy (or an eBPF dataplane) programs the node so traffic to the Service IP is forwarded to one of those pod IPs. Cluster DNS gives every Service a name like orders.shop.svc.cluster.local, so applications connect by name instead of IP.
ClusterIP (the default) is reachable only inside the cluster. NodePort additionally opens a port (30000-32767 by default) on every node. LoadBalancer asks the cloud provider (or MetalLB on bare metal) for an external load balancer that forwards to the Service. A headless Service (clusterIP: None) skips the virtual IP and returns individual pod IPs from DNS, which StatefulSets and client-side load balancing use.
Service types
| Type | Reachable from | Typical use |
|---|---|---|
| ClusterIP | Inside the cluster | Internal APIs, databases, caches |
| NodePort | Node IP:port | Simple external access, behind your own LB |
| LoadBalancer | External IP from cloud LB | Expose a service directly to the internet |
| Headless (None) | DNS returns pod IPs | StatefulSets, client-side balancing |
| ExternalName | DNS CNAME to external host | Alias an external service |
How traffic is routed
LoadBalancer layering
Practical examples
A ClusterIP Service
port is what clients use; targetPort is the container port.
apiVersion: v1
kind: Service
metadata: { name: orders, namespace: shop }
spec:
selector: { app: orders }
ports:
- name: http
port: 80
targetPort: 8080Debug a Service that returns nothing
Most issues are selectors or readiness.
kubectl get endpointslices -l kubernetes.io/service-name=orders -n shop
kubectl get pods -n shop -l app=orders --show-labels
kubectl run tmp --rm -it --image=busybox -n shop -- wget -qO- http://orders/healthPort-forward for local testing
Reach a ClusterIP Service from your laptop.
kubectl port-forward svc/orders 8080:80 -n shop
curl localhost:8080/healthCommon mistakes
- Selector labels that do not match pod labels, leaving the Service with no endpoints.
- Pods not ready (failing readiness probe), so they are excluded from endpoints.
- One LoadBalancer Service per app, multiplying cloud load balancer costs instead of using Ingress/Gateway.
- Confusing port and targetPort.
Key takeaways
- Services give pods a stable IP and DNS name.
- ClusterIP internal, NodePort node-level, LoadBalancer external, headless for pod DNS.
- Endpoints include only ready pods matching the selector.
- Debug with endpointslices, labels and a test pod.
FAQ
Does a Service load-balance per request?
kube-proxy balances per connection; long-lived connections (HTTP/2, gRPC) may stick to one pod, so use client-side balancing or a mesh for even distribution.
How do I expose many HTTP services?
Use an Ingress controller or the Gateway API with one load balancer routing by host and path.
Can a Service point to things outside the cluster?
Yes, with ExternalName or a Service without a selector plus manually managed endpoints.