Services and Networking

Harry · 11 Sep 2026 · 9 views

Why Services?

Pods come and go and get new IPs constantly. A Service gives a stable virtual IP and DNS name in front of a set of pods, selected by labels.

Service Types

  • ClusterIP (default) - internal virtual IP; reachable only inside the cluster.
  • NodePort - exposes the service on a port of every node.
  • LoadBalancer - provisions an external load balancer (common on cloud providers).
  • ExternalName - a DNS alias to an external host.

A Service Manifest

apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
  - port: 80
    targetPort: 80
  type: ClusterIP
kubectl apply -f service.yaml
kubectl get svc web
kubectl get endpoints web   # shows the pod IPs behind the service

Service Discovery

Inside the cluster, a pod can reach another service by name: http://web:80. Kubernetes uses DNS (CoreDNS) for this automatically.

Key Points

  • Services select pods with label selectors.
  • ClusterIP is for pod-to-pod traffic; NodePort/LoadBalancer expose the app externally.
  • CoreDNS maps service names to virtual IPs cluster-wide.
Share this post:

Comments (0)

Please login or register to comment.