DEV Community

Cover image for Part-82: Kubernetes Service — LoadBalancer
Latchu@DevOps
Latchu@DevOps

Posted on

Part-82: Kubernetes Service — LoadBalancer

Kubernetes Service

When we deploy applications on Kubernetes, Pods are short-lived and their IPs change when rescheduled. To provide stable access to Pods, Kubernetes uses Services.

s1


Step-01: What are Services in Kubernetes?

A Service is an abstraction that defines a logical set of Pods and a policy by which to access them. In other words: Services provide stable networking to Pods.

Types of Services in Kubernetes:

  • ClusterIP (default): Exposes the app inside the cluster only.
  • NodePort: Exposes the app on every Node’s IP at a static port.
  • LoadBalancer: Exposes the app externally via a Cloud Provider’s Load Balancer.
  • Ingress: Smart routing and HTTPS termination in front of multiple Services.

Step-02: What is a LoadBalancer Service?

  • If we want to access our app from the internet, we use a LoadBalancer Service.
  • In GKE (Google Kubernetes Engine), when we create a Service of type LoadBalancer, Kubernetes automatically provisions:
  1. A Google Cloud Load Balancer
  2. A Google Cloud External IP Address

This external IP is what users will use to access the application.


Step-03: How does it work?

s2

Refer to the diagram above. Let’s walk through it step by step:

User Access:

A user opens a browser and enters the external IP, for example:

http://34.120.55.100
Enter fullscreen mode Exit fullscreen mode

Cloud Load Balancer:

That request hits the Google Cloud Load Balancer, which was automatically created by Kubernetes when we deployed the LoadBalancer Service.

Kubernetes Service (Port Mapping):

  • The Service listens on a port (e.g., 80) and routes traffic to Pods.
  • Inside the Service, port (ClusterIP port) forwards traffic to the Pod’s targetPort.
  • Example: Service port: 80 → Pod containerPort: 80.

Pod Level (Container):

Finally, the request reaches the Pod running the NGINX container on port 80.
The container processes the request and sends the response back through the same chain → Service → Load Balancer → User’s browser.


🌟 Thanks for reading! If this post added value, a like ❤️, follow, or share would encourage me to keep creating more content.


— Latchu | Senior DevOps & Cloud Engineer

☁️ AWS | GCP | ☸️ Kubernetes | 🔐 Security | ⚡ Automation
📌 Sharing hands-on guides, best practices & real-world cloud solutions

Top comments (0)