This guide explains the four primary Kubernetes Service types using a sample NGINX deployment to help expose applications inside and outside the cluster.
Use this file to discover all available pages before exploring further.
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.
kubectl run -i --tty --rm debug --image=curlimages/curl --restart=Never -- sh
Inside the debug pod:
nslookup headless-svc.default.svc.cluster.localfor ip in $(nslookup headless-svc.default.svc.cluster.local | grep Address | awk '{print $2}'); do curl http://$ipdone
Headless Services are ideal for stateful applications (e.g., databases) where you need direct pod access for persistent storage or custom load balancing.
kubectl run -i --tty --rm debug --image=curlimages/curl --restart=Never -- sh# Inside the pod:curl http://externalname-svc.default.svc.cluster.local/get# This request is forwarded to httpbin.org/get
ExternalName does not proxy traffic through the cluster—it simply performs a DNS CNAME lookup. Use this to reference external APIs or services.