A developer deploys a set of Pods labeled app=frontend and wants to expose them internally within the cluster on a stable IP. Which resource should be used?
Trap 1: Service of type NodePort
A NodePort Service exposes the Pods on a static port (30000–32767) on every node, making them reachable from outside the cluster via nodeIP:nodePort. For internal-only Pod-to-Pod communication, this is unnecessary and creates an external network exposure surface that increases security risk and consumes a node port that may conflict with other services. Since the frontend Pods only need to reach the backend inside the cluster, a ClusterIP Service provides the required stable internal IP without opening any external ingress path.
Trap 2: Service of type LoadBalancer
A LoadBalancer Service provisions a cloud provider load balancer (e.g., AWS ELB, GCP LB, Azure LB) and assigns a public IP address, providing external access to the Pods from the internet. This is completely overkill for internal access because the frontend Pods and backend Pods are already in the same cluster, and the load balancer introduces public exposure, additional cost, and cloud provider dependency. The correct internal solution is a ClusterIP Service, which is not exposed outside the cluster and is automatically discoverable by other Pods via DNS.
Trap 3: Ingress resource
An Ingress resource is not a Service type; it is a Kubernetes API object that manages external HTTP(S) traffic to Services, typically via an Ingress controller like NGINX or HAProxy. To route traffic, Ingress must point to a backend Service (often ClusterIP) that ultimately targets the Pods, so it does not itself provide a stable internal IP for frontend-to-backend communication. Adding an Ingress would introduce an unnecessary external routing layer and still require a Service, making it an incorrect and over-engineered choice for internal-only access.
- A
Service of type NodePort
Why wrong: A NodePort Service exposes the Pods on a static port (30000–32767) on every node, making them reachable from outside the cluster via nodeIP:nodePort. For internal-only Pod-to-Pod communication, this is unnecessary and creates an external network exposure surface that increases security risk and consumes a node port that may conflict with other services. Since the frontend Pods only need to reach the backend inside the cluster, a ClusterIP Service provides the required stable internal IP without opening any external ingress path.
- B
Service of type LoadBalancer
Why wrong: A LoadBalancer Service provisions a cloud provider load balancer (e.g., AWS ELB, GCP LB, Azure LB) and assigns a public IP address, providing external access to the Pods from the internet. This is completely overkill for internal access because the frontend Pods and backend Pods are already in the same cluster, and the load balancer introduces public exposure, additional cost, and cloud provider dependency. The correct internal solution is a ClusterIP Service, which is not exposed outside the cluster and is automatically discoverable by other Pods via DNS.
- C
Service of type ClusterIP
A ClusterIP Service is the default and correct Service type for internal-only communication. It assigns a stable virtual IP from the cluster's service CIDR that is reachable only from inside the cluster, and it provides built-in load balancing across the backend Pods via iptables/IPVS rules managed by kube-proxy. The frontend Pods can reliably resolve the Service by DNS name and connect to it, without any external exposure, which exactly matches the requirement for a backend that should not be accessible from outside the cluster.
- D
Ingress resource
Why wrong: An Ingress resource is not a Service type; it is a Kubernetes API object that manages external HTTP(S) traffic to Services, typically via an Ingress controller like NGINX or HAProxy. To route traffic, Ingress must point to a backend Service (often ClusterIP) that ultimately targets the Pods, so it does not itself provide a stable internal IP for frontend-to-backend communication. Adding an Ingress would introduce an unnecessary external routing layer and still require a Service, making it an incorrect and over-engineered choice for internal-only access.