CKAD — Endpoints & Headless Services

less than 1 minute read

Endpoints

Endpoints track the actual Pod IPs behind a Service.

# View endpoints
kubectl get endpoints web
# Expected:
# NAME   ENDPOINTS                                AGE
# web    10.1.0.5:80,10.1.0.6:80,10.1.0.7:80     5m

# Detailed view
kubectl describe endpoints web

If a Service has no matching Pods (wrong selector), the Endpoints list will be empty.

Headless Services

A headless Service (ClusterIP: None) does not get a cluster IP. Instead, DNS returns the individual Pod IPs.

apiVersion: v1
kind: Service
metadata:
  name: db-headless
spec:
  clusterIP: None
  selector:
    app: database
  ports:
  - port: 5432
kubectl run test --image=busybox:1.36 --rm -it -- nslookup db-headless
# Returns individual Pod IPs instead of a single Service IP

Use cases:

  • StatefulSets where each Pod needs a unique DNS name
  • Client-side load balancing
  • Service discovery without proxying

Port Forwarding

For quick debugging, forward a local port to a Pod or Service:

# Forward to a Pod
kubectl port-forward pod/web-xyz123 8080:80

# Forward to a Service
kubectl port-forward svc/web 8080:80

# Forward to a specific port in a Deployment
kubectl port-forward deployment/web 8080:80

# Access on localhost:8080
curl http://localhost:8080

Port forwarding is not for production — use it for debugging and testing.


Next: Service Commands →

Updated: