1

I am trying to follow this tutorial https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-service

What confuses me is

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

Can some explain if this will balance load across the pods in the node? I want to, say, make 5 requests to the service of a deployment with 5 pods and want each pod to handle each request in parallel. How can I make minikube equally distribute requests across pods in a node?

Edit: There is also --type=NodePort how does it differ from type LoadBalancer above? Do any of these distribute incoming requests across pods on its own?

  • I found https://stackoverflow.com/a/44112285/7343529 here that there is no auto loadbalancing for minikube, but then why the minikube tutorial https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-service have it at first place? – Muhammad Mohib Khan Aug 04 '19 at 16:25
  • minikube supports the service type `LoadBalancer` using `minikube tunnel`. But this is not the point, there is a concept called `LoadBalancer` which does not automatically load balance - it is dependant on external infrastructure. And there is the concept of a `Service` which does load balance *inside* kubernetes. – Thomas Aug 04 '19 at 16:49

1 Answers1

2

A service is the way to expose your deployment to external requests. Type loadbalancer gives the service an external ip which will forward your request to the deployment. The deployment defaults to round Robin (based on the docs). If you want different types of load balancing use istio or another service mesh

Yonah Dissen
  • 1,197
  • 1
  • 8
  • 16
  • Is there is a way that Kubernetes itself loadbalances across pods in minikube without using any other service? – Muhammad Mohib Khan Aug 04 '19 at 15:30
  • 1
    The kubernetes deployment will loadbalance between its pods. The service I am referring to is a kubernetes service (not external)https://kubernetes.io/docs/concepts/services-networking/service/ – Yonah Dissen Aug 04 '19 at 15:36
  • I feel your answer is in contrast to what i just found https://stackoverflow.com/a/44112285/7343529 ? – Muhammad Mohib Khan Aug 04 '19 at 16:14
  • You can create a type loadbalancer also in minikube . https://metallb.universe.tf/. In any case I was explaining the concept of type loadbalancer – Yonah Dissen Aug 05 '19 at 07:22