Kubernetes LoadBalancer Service Guide
Expose Kubernetes services with LoadBalancer type for production traffic. Covers cloud providers, MetalLB for bare-metal, health checks, and cost optimization.
π‘ Quick Answer: networking
The Problem
This is one of the most searched Kubernetes topics with thousands of monthly searches. A comprehensive, production-ready guide prevents hours of trial and error.
The Solution
Create LoadBalancer Service
apiVersion: v1
kind: Service
metadata:
name: web-lb
annotations:
# AWS-specific
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
# GKE-specific
# cloud.google.com/neg: '{"ingress": true}'
spec:
type: LoadBalancer
selector:
app: web
ports:
- port: 80
targetPort: 8080
- port: 443
targetPort: 8443# Check external IP
kubectl get svc web-lb
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
# web-lb LoadBalancer 10.96.10.50 203.0.113.100 80:31234/TCP,443:31235/TCP
# Access
curl http://203.0.113.100MetalLB for Bare-Metal
helm repo add metallb https://metallb.universe.tf
helm install metallb metallb/metallb --namespace metallb-system --create-namespace# IP address pool
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: production
namespace: metallb-system
spec:
addresses:
- 192.168.1.200-192.168.1.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default
namespace: metallb-system
spec:
ipAddressPools: [production]Internal Load Balancer
metadata:
annotations:
# AWS: internal NLB
service.beta.kubernetes.io/aws-load-balancer-scheme: internal
# GKE: internal LB
networking.gke.io/load-balancer-type: Internal
# Azure: internal LB
service.beta.kubernetes.io/azure-load-balancer-internal: "true"Cost Tip
# Each LoadBalancer creates a cloud LB ($15-20/mo each!)
# Use ONE Ingress Controller with LoadBalancer β route to many services
# Instead of:
# Service A β LoadBalancer ($20/mo)
# Service B β LoadBalancer ($20/mo)
# Service C β LoadBalancer ($20/mo)
# Use:
# Ingress Controller β 1 LoadBalancer ($20/mo) β routes to A, B, Cgraph TD
A[Internet] --> B[Cloud Load Balancer]
B --> C[Node 1: kube-proxy]
B --> D[Node 2: kube-proxy]
C --> E[Pod]
D --> E
F[Bare metal] --> G[MetalLB: ARP/BGP]
G --> H[Assigns IP from pool]
H --> I[Routes to pods]Frequently Asked Questions
LoadBalancer stuck on Pending EXTERNAL-IP?
On cloud: check IAM permissions for LB creation. On bare-metal: you need MetalLB or similar β Kubernetes canβt create LBs without a provider.
One LoadBalancer per service?
Yes β each Service of type LoadBalancer gets its own cloud LB. This gets expensive. Use Ingress to multiplex many services behind one LB.
Best Practices
- Start with the simplest configuration that solves your problem
- Test in staging before production
- Use
kubectl describeand events for troubleshooting - Document team conventions for consistency
Key Takeaways
- This is fundamental Kubernetes operational knowledge
- Follow established conventions and recommended labels
- Monitor and iterate based on real production behavior
- Automate repetitive tasks to reduce human error

Recommended
Kubernetes Recipes β The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book βLearn by Doing
CopyPasteLearn β Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses βπ Deepen Your Skills β Hands-on Courses
Courses by CopyPasteLearn.com β Learn IT by Doing
