Kubernetes interview question · Most asked

Explain the Service types: ClusterIP, NodePort, LoadBalancer, ExternalName and headless.

Summary

A Service gives a stable virtual IP and DNS name in front of a changing set of pods selected by labels. ClusterIP is reachable only inside the cluster; NodePort also opens a port on every node; LoadBalancer provisions a cloud load balancer; ExternalName is a DNS alias to an outside name; a headless Service (clusterIP: None) returns the pod IPs directly in DNS, used by StatefulSets.

Longer Answer

Endpoints are maintained as EndpointSlices containing only ready pods. kube-proxy (iptables, IPVS or nftables mode) or an eBPF data path (such as Cilium) translates the virtual IP to pod IPs on each node.

For HTTP from outside, you usually expose many Services through one Ingress or Gateway rather than one cloud load balancer per Service, which costs more. externalTrafficPolicy: Local preserves the client IP and avoids an extra hop, but only nodes with local pods receive traffic.

Key Points

  • Stable VIP and DNS for a label selector.
  • ClusterIP, NodePort, LoadBalancer, ExternalName.
  • Headless returns pod IPs.
  • EndpointSlices hold only ready pods.

More most-asked Kubernetes questions

← All Kubernetes questions