πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Networking beginner ⏱ 15 minutes K8s 1.28+

Kubernetes Service Types Explained

Understand ClusterIP, NodePort, LoadBalancer, and ExternalName service types in Kubernetes. When to use each type with practical examples and comparisons.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Understand ClusterIP, NodePort, LoadBalancer, and ExternalName service types in Kubernetes. When to use each type with practical examples and comparisons.

The Problem

This is one of the most searched Kubernetes topics. Having a comprehensive, well-structured guide helps both beginners and experienced users quickly find what they need.

The Solution

The Four Service Types

# ClusterIP (default) β€” internal only
apiVersion: v1
kind: Service
metadata:
  name: backend-api
spec:
  type: ClusterIP
  selector:
    app: backend
  ports:
    - port: 80
      targetPort: 8080
# Access: backend-api.default.svc.cluster.local:80
---
# NodePort β€” expose on every node's IP
apiVersion: v1
kind: Service
metadata:
  name: web-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080    # 30000-32767 range
# Access: <any-node-ip>:30080
---
# LoadBalancer β€” cloud load balancer
apiVersion: v1
kind: Service
metadata:
  name: web-public
spec:
  type: LoadBalancer
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
# Access: <external-ip>:80
---
# ExternalName β€” DNS alias to external service
apiVersion: v1
kind: Service
metadata:
  name: external-db
spec:
  type: ExternalName
  externalName: db.example.com
# Access: external-db.default.svc β†’ CNAME β†’ db.example.com

Comparison

TypeScopeUse CaseCost
ClusterIPInternal onlyService-to-serviceFree
NodePortExternal via node IPDev/testing, bare metalFree
LoadBalancerExternal via cloud LBProduction cloud$$$ per LB
ExternalNameDNS aliasExternal servicesFree

Headless Service (StatefulSets)

apiVersion: v1
kind: Service
metadata:
  name: postgres
spec:
  clusterIP: None     # Headless β€” no load balancing
  selector:
    app: postgres
  ports:
    - port: 5432
# DNS returns individual pod IPs:
# postgres-0.postgres.default.svc.cluster.local
# postgres-1.postgres.default.svc.cluster.local
graph TD
    A[Client inside cluster] --> B[ClusterIP: 10.96.x.x]
    B --> C[Pod 1]
    B --> D[Pod 2]
    E[External client] --> F[NodePort: node:30080]
    F --> B
    G[External client] --> H[LoadBalancer: external-ip:80]
    H --> B

Frequently Asked Questions

When should I use LoadBalancer vs Ingress?

Use LoadBalancer for non-HTTP traffic (databases, gRPC) or single services. Use Ingress for HTTP routing to multiple services with path/host-based rules β€” one LoadBalancer for many services.

What is ClusterIP None (headless service)?

A headless service doesn’t get a cluster IP. DNS returns individual pod IPs instead of load-balancing. Required for StatefulSets where clients need to reach specific pods.

Best Practices

  • Start simple β€” use the basic form first, add complexity as needed
  • Be consistent β€” follow naming conventions across your cluster
  • Document your choices β€” add annotations explaining why, not just what
  • Monitor and iterate β€” review configurations regularly

Key Takeaways

  • This is fundamental Kubernetes knowledge every engineer needs
  • Start with the simplest approach that solves your problem
  • Use kubectl explain and kubectl describe when unsure
  • Practice in a test cluster before applying to production
#service #clusterip #nodeport #loadbalancer #networking #kubernetes
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens