0

I learnt that Kubernetes running via Minikube or kind (that's what I'm using) does not have a Load Balancer. That functionality comes from cloud providers. However, when I created a simple deployment with 3 replicas and a service:

kubectl create deployment kiada --image=luksa/kiada:0.1
kubectl scale deployment kiada --replicas=3
kubectl expose deployment kiada --type=LoadBalancer --port 8080

I am able to reach different pods via :8080.

My local cluster has 2 worker nodes. When I hit the :8080 I sometimes get a response from a pod running on worker-1, and sometimes I get a response from another pod running on node worker-2. Isn't that load balancing?

With that, I do not understand why it is said that Kubernetes does not provide load balancing by itself, since I can see that it clearly does.

mnj
  • 2,539
  • 3
  • 29
  • 58

1 Answers1

3

A Kubernetes Service will load balance requests to any of the Pods matching the labels specified in the Service.

Don't mix this with type: LoadBalancer which is a way to expose your Service using a Cloud Load Balancer, typically with an external IP address.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • 1
    I did further reading ("Kubernetes in Action"), and I learnt that there are actually two load balancers. One provided by the cloud provider (if a given K8s is running in the cloud, and is managed) - it load balances traffic between worker nodes. The other load balancer is built into K8s and it load balances between pods. – mnj Oct 02 '21 at 18:11
  • @mnj, actually you can even configure different replica of the same pods on different nodes so that the k8s cluster ip service will load balance between different nodes. – Nolan Edric Mar 28 '22 at 10:22