Skip to main content

LoadBalancer

LoadBalancer exposes the Service externally using an external load balancer.

Kubernetes does not directly offer a load balancing component; we must provide one, or integrate our cluster with a cloud provider.

note

With the Minikube setup we have currently, testing the LoadBalancer Service type is not feasible. However, we will just learn the theory part.

LoadBalancer Definition​

Though we are not actually creating a load balancer, below is an example manifest file.

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

The load balancer will created asynchronously. Traffic is directed to the backend Pods. The cloud provider decides the load balancing strategy.