A Kubernetes Service is an abstraction that defines a logical set of Pods and a policy to access them. It operates at Layer 4 (TCP/UDP).

flowchart LR
  client[Client]
  svc[Service<br/>IP: 10.96.0.10]
  pod1[Pod A<br/>IP: 10.244.0.5]
  pod2[Pod B<br/>IP: 10.244.0.6]

  client --> svc
  svc --> pod1
  svc --> pod2

  style svc fill:#f9f,stroke:#333,stroke-width:2px
  style pod1 fill:#bbf,stroke:#333
  style pod2 fill:#bbf,stroke:#333
  • The Service IP (10.96.0.10) is a virtual IP stable for clients.
  • The Pod IPs (10.244.x.x) are assigned dynamically from the node’s CNI.
  • The Service acts as a load-balancing proxy to the actual pods.

🎯 Purpose

  • Enables stable networking for ephemeral Pods
  • Abstracts Pod IPs behind a consistent virtual IP (ClusterIP)

🧱 Types

  • ClusterIP: Default, internal-only access
  • NodePort: Opens a static port on each node
  • LoadBalancer: Provisions external access via a cloud or MetalLB
  • ExternalName: Maps to a DNS name outside the cluster

🔧 Example

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ClusterIP
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 8080