When do you use ClusterIP, NodePort, LoadBalancer and ExternalName?
BeginnerScenarioServices, Ingress and DNS
Answer
Situation read → A developer asks how to expose a new internal API and a public website.
What I'd do →
- ClusterIP for in-cluster traffic, the default
- NodePort mostly for debugging or when a load balancer sits in front
- LoadBalancer to get a cloud LB per Service, such as an NLB on EKS
- Ingress or Gateway API in front of many HTTP services to share one LB
- ExternalName to alias an external DNS name through a cluster DNS CNAME
Why → Each type builds on the previous: LoadBalancer includes NodePort, which includes ClusterIP.
Interview tip → Say that you rarely give every service its own LB in production because of cost.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?IntermediateA pod cannot resolve `my-svc` but can reach the pod IP. What do you test first?Beginner