DEV Community

Shiva Charan
Shiva Charan

Posted on

Definition of Services in Kubernetes

A Service in Kubernetes is an object that provides a stable IP address, DNS name, and consistent network access to a group of Pods.

Because Pods are temporary — they die, restart, or get new IPs — a Service makes sure that:

  • ✔ Applications can find and talk to Pods reliably
  • ✔ Network traffic is load-balanced across Pods
  • ✔ The communication remains stable even if Pods change

🧠 Why Services Exist

Pods are not permanent:

  • Their IPs keep changing
  • Pods come and go during scaling
  • New Pods replace old Pods during deployments

Without Services, apps would have no stable way to reach Pods.

A Service hides Pod changes behind a fixed, reliable endpoint.


🎯 What a Service Provides

🔹 Stable ClusterIP

A virtual IP that does NOT change.

🔹 DNS name

Example:

myapp.default.svc.cluster.local
Enter fullscreen mode Exit fullscreen mode

🔹 Load balancing

Traffic is automatically distributed to healthy Pods.

🔹 Service Discovery

Apps always know how to find each other.


🏗️ How Services Work Internally

A Service selects Pods using labels:

selector:
  app: myapp
Enter fullscreen mode Exit fullscreen mode

Then Kubernetes creates:

  • Endpoints/EndpointSlices = list of Pod IPs behind the Service
  • Rules in kube-proxy (iptables/ipvs) to route traffic

When you access the Service IP → kube-proxy forwards the request to one of the matching Pods.


📝 One-Line Interview Definition

A Service in Kubernetes is a stable networking endpoint that 
provides consistent access, load balancing, and 
discovery to a dynamic group of Pods.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)