100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
YAML

Services and Networking

Understand how Kubernetes Services provide stable networking identities and load balancing for ephemeral, dynamically scheduled Pods.

Kubernetes WorkloadsIntermediate11 min readJul 8, 2026
Analogies

The Problem Services Solve

Pods are ephemeral -- they get new IP addresses every time they are recreated. Applications cannot reliably talk to individual Pod IPs. A Kubernetes Service provides a stable virtual IP and DNS name that load-balances traffic across a dynamic set of Pods selected by labels, so consumers never need to track Pod churn.

🏏

Cricket analogy: Like fans following a franchise's name and jersey number rather than tracking which specific player wears it season to season, a Kubernetes Service gives a stable virtual IP and DNS name that abstracts away which Pods currently back it.

ClusterIP: Internal-Only Access

ClusterIP is the default Service type. It exposes the Service on an internal, cluster-only virtual IP that is reachable from any Pod in the cluster, typically via DNS at <service-name>.<namespace>.svc.cluster.local. It is the right choice for backend services that should never be reachable from outside the cluster.

🏏

Cricket analogy: Like an internal team-only training ground that outside spectators can never enter, but any player on the squad can use it, ClusterIP exposes a Service only inside the cluster, reachable via internal DNS, never externally.

yaml
apiVersion: v1
kind: Service
metadata:
  name: backend
spec:
  type: ClusterIP
  selector:
    app: backend
  ports:
    - name: http
      port: 80
      targetPort: 8080
      protocol: TCP

NodePort: Exposing a Static Port on Every Node

A NodePort Service allocates a port in the 30000-32767 range on every node and forwards traffic from that port to the Service, which then load-balances to matching Pods. It is mainly used for development, on-prem clusters without a cloud load balancer, or as the underlying mechanism for Ingress controllers.

🏏

Cricket analogy: Like a stadium reserving a fixed gate number that any fan can use to eventually reach their seat, even though the exact usher on duty changes, a NodePort opens a fixed port on every node that forwards to the Service.

yaml
apiVersion: v1
kind: Service
metadata:
  name: web-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080

LoadBalancer: Cloud-Provisioned External Access

On a supported cloud provider, a LoadBalancer Service provisions an external load balancer (for example an AWS NLB or GCP Load Balancer) that routes to the Service, which in turn routes to NodePort and then to Pods. It builds on top of NodePort and ClusterIP rather than replacing them.

🏏

Cricket analogy: Like a stadium hiring a dedicated external ticketing agency that routes fans through the regular gate system rather than replacing it, a LoadBalancer Service provisions an external load balancer that routes through NodePort and ClusterIP.

yaml
apiVersion: v1
kind: Service
metadata:
  name: web-lb
spec:
  type: LoadBalancer
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080

Setting clusterIP: None creates a headless Service. Instead of a single virtual IP, DNS returns the individual Pod IPs directly, which is essential for StatefulSets where clients need to address specific Pod replicas by stable hostname. Under the hood, kube-proxy implements Service load balancing on each node, usually via iptables or IPVS rules that redirect virtual-IP traffic to the healthy backend Pod IPs tracked by the EndpointSlice objects.

🏏

Cricket analogy: Like a scorer's directory listing every individual player's personal contact rather than just the team hotline, so a specific player can always be reached directly, a headless Service returns individual Pod IPs instead of one virtual IP.

A Service only routes to Pods whose readiness probe is currently passing. A Pod that is Running but not Ready is silently excluded from the Endpoints/EndpointSlice, which is a common source of confusing 'why is my Pod not getting traffic' bugs.

  • ClusterIP (default) is internal-only; NodePort exposes a port on every node; LoadBalancer provisions an external cloud load balancer.
  • Services select Pods via label selectors, not by Pod name -- keep labels consistent between Deployments and Services.
  • kube-proxy programs iptables/IPVS rules based on EndpointSlices to implement Service load balancing.
  • Headless Services (clusterIP: None) return individual Pod IPs, used heavily by StatefulSets.
  • Only Ready Pods receive traffic through a Service.
  • Ingress operates at Layer 7 (HTTP/HTTPS) and typically routes to ClusterIP Services, not replacing them.

Practice what you learned

Was this page helpful?

Topics covered

#YAML#DockerKubernetesStudyNotes#DevOps#ServicesAndNetworking#Services#Networking#Problem#Solve#StudyNotes#SkillVeris