Course contentsShow
← Cloud and Infrastructure
Lesson 1208 of 2,98924. Kubernetes NetworkingFree lesson

LoadBalancer Service Type

Provisioning cloud provider load balancers to expose Services with external IPs.

LoadBalancer Service Type

What You'll Learn

You'll learn how Kubernetes automatically provisions cloud provider load balancers to expose your Services to the internet with stable external IP addresses.

The Need for External Access

You've seen ClusterIP (internal-only) and NodePort (accessible via node IPs). But what if you want a production-grade, stable external IP without manually managing ports or remembering node addresses? That's where LoadBalancer comes in.

How LoadBalancer Works

When you create a Service with type: LoadBalancer, Kubernetes automatically requests your cloud provider (AWS, GCP, Azure, etc.) to provision an external load balancer. This load balancer:

  • Gets a public IP address or DNS name
  • Distributes traffic across all healthy Pods matching your Service's selector
  • Integrates with the cloud's native load balancing infrastructure

Think of it like calling a taxi service: you don't need to know which specific driver will come—you just request a ride, and the service handles dispatching and routing.

Basic Manifest Structure

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

This creates a cloud load balancer forwarding port 80 traffic to your Pods on port 8080.

Behind the Scenes

Kubernetes actually creates a NodePort first, then configures the cloud load balancer to route to those node ports. You get the best of both worlds: stable external access plus automatic integration with cloud infrastructure.

Platform Requirements

This only works on supported cloud platforms (EKS, GKE, AKS, etc.) or with a compatible load balancer controller. On bare-metal clusters, you'd need solutions like MetalLB.

Key Takeaway: The LoadBalancer Service type automatically provisions cloud-native load balancers with stable external IPs, making your applications accessible from the internet without manual port management.