Skip to content
StackDecode
BeginnerLesson 7 of 35

Services

A stable address and load balancer in front of changing pods.

Pod IPs change. A Service gives a fixed virtual IP and DNS name and spreads traffic across pods matching its selector.

yaml
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector: { app: web }
  ports:
    - port: 80
      targetPort: 80
  • ClusterIP (default): internal only.
  • NodePort: opens a port on every node.
  • LoadBalancer: asks the cloud for an external load balancer.
  • ExternalName: a DNS alias to an outside host.

Inside the cluster, reach it at web.<namespace>.svc.cluster.local or just web.