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)