Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsMedium

A developer has created a YAML manifest for a Pod and applied it to the cluster. The Pod is running, but they are unable to access the application inside the Pod from outside the cluster. They want to set up a basic, quick way to expose the Pod's application on a specific port on each of the cluster's worker nodes for testing purposes. Which type of Service should they create?

  1. AClusterIP
  2. BLoadBalancer
  3. CExternalName
  4. DNodePort
Show answer & explanation

Correct answer: D. NodePort

A NodePort Service exposes the Service on a static port on each Node's IP address. This allows external traffic to reach the Service by accessing any Node's IP on that specific port, which is a straightforward way to expose applications for testing outside the cluster.

Why the other options are wrong

  • A. A ClusterIP Service provides an internal IP only, making it unreachable from outside the cluster.
  • B. A LoadBalancer Service requires a cloud provider integration and typically provisions an external load balancer, which might be overkill for 'basic, quick testing'.
  • C. An ExternalName Service maps to an external DNS name, not for exposing an internal Pod directly.

Kubernetes NodePort Service

A Kubernetes Service type that exposes the Service on a static port (the NodePort) on each of the cluster's worker Nodes. This makes the Service accessible from outside the cluster by hitting <NodeIP>:<NodePort>.

  • Exposes Service on a static port on each Node.
  • Allows external access to internal services.
  • Often used for development, testing, or exposing a small number of services.

Memory trick: NodePort for Node Access, ClusterIP for Internal, LoadBalancer for Cloud.

More Kubernetes Fundamentals questions