Skip to main content
In this guide, you’ll learn about the four primary Kubernetes Service types—ClusterIP, NodePort, Headless, and ExternalName—using a sample NGINX deployment. Understanding these service types will help you expose applications both inside and outside your cluster.

Overview of Service Types

Before diving in, we’ve deployed three NGINX pods with the label role=nginx in the default namespace:

1. ClusterIP (Default)

ClusterIP is the Kubernetes default service type. It allocates a virtual IP reachable only within the cluster.

1.1 Service Definition

1.2 Testing Internal Access

Launch a temporary pod to test DNS and HTTP:
Inside the debug pod:
ClusterIP services are only reachable from within the Kubernetes cluster. Use them for internal microservice communication.

2. NodePort

NodePort exposes a Service on each Node’s IP at a static port, allowing external traffic.

2.1 Service Definition

2.2 Access via Node IP

  1. Find a node’s IP address:
  2. From outside the cluster:
    This should return the NGINX welcome page.
Ensure that your cloud provider’s firewall or on-premise network allows traffic to the nodePort range (default 30000–32767).

2.3 Internal DNS Resolution

Within the cluster, you can still resolve the service by DNS:

3. Headless Service

A headless Service omits the cluster IP (clusterIP: None) and returns the IPs of individual pods directly.

3.1 Service Definition

3.2 DNS and Direct Pod Access

Inside the debug pod:
Headless Services are ideal for stateful applications (e.g., databases) where you need direct pod access for persistent storage or custom load balancing.

4. ExternalName

ExternalName maps a Service to an external DNS name by returning a CNAME record.

4.1 Service Definition

4.2 Testing ExternalName

ExternalName does not proxy traffic through the cluster—it simply performs a DNS CNAME lookup. Use this to reference external APIs or services.

Further Reading & References

Watch Video

Practice Lab