Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsMedium
A platform engineer is designing the network for a new microservice in Kubernetes. They need to ensure that internal services can communicate with this microservice using a stable DNS name, but the microservice should not be directly exposed to external traffic. Which type of Kubernetes Service should be used?
- AExternalName
- BNodePort
- CLoadBalancer
- DClusterIP
Show answer & explanationAnswer & explanation
Correct answer: D. ClusterIP
A ClusterIP Service exposes the Service on an internal IP in the cluster. This makes the Service only reachable from within the cluster, providing a stable internal DNS name and IP address, which perfectly matches the requirement for internal communication without external exposure.
Why the other options are wrong
- A. ExternalName maps the Service to a CNAME record, used for external services, not for internal microservices within the cluster.
- B. NodePort exposes the Service on a static port on each Node's IP, making it externally accessible.
- C. LoadBalancer exposes the Service externally using a cloud provider's load balancer.
Kubernetes ClusterIP Service
A Kubernetes Service type that exposes the Service on an internal IP address within the cluster. It is only reachable from within the cluster and provides a stable internal DNS name for communication.
- Default Service type.
- Provides a stable internal IP and DNS name.
- Not exposed to external traffic.
Memory trick: Cluster for internal, Node for node-level, LoadBalancer for cloud, External for external.