Services: Networking & Discovery
Pods are ephemeral: their IP addresses change every time they are restarted or rescheduled. A Service provides a stable virtual IP address and DNS name to route traffic reliably to matching Pods.
1. Service Types
Section titled “1. Service Types”- ClusterIP (Default): Exposes the Service on a cluster-internal IP. Reachable only within the cluster.
- NodePort: Exposes the Service on each Node’s IP at a static port (in the range 30000–32767).
- LoadBalancer: Provisions an external cloud load balancer (AWS NLB, GCP Load Balancer) pointing to NodePorts.
- ExternalName: Maps the Service to the contents of the
externalNamefield (e.g.api.stripe.com) returning a CNAME record. - Headless (
clusterIP: None): Direct DNS resolution returning the individual IPs of all matching Pods (used by StatefulSets).
2. Service Manifest
Section titled “2. Service Manifest”apiVersion: v1kind: Servicemetadata: name: web-backendspec: type: ClusterIP selector: app: backend ports: - name: http port: 80 targetPort: 8080