LoadBalancer in Kubernetes

2/5/2019

I have installed kubernetes using minikube on a single node. I have implemented ‘LoadBalancer’ type of service which manages 3 pods. By default, it uses a ‘network load balancer’. Can we change load balancer type in service .yaml file or can we change load balancer algorithm used? please find the service file below :

— myservice.yaml

apiVersion: v1
kind: Service
metadata:
  name: demo-apps-lb
spec:
  type: LoadBalancer
  ports:
    port: 80
  selector:
      app: app1

Note : Here I am not using any cloud platform, all the things are on single host machine.

-- kalyani chaudhari
kubernetes
load-balancing
minikube

3 Answers

2/5/2019

If you use load balancer type service on cloud , cloud provider will create load balancer for you and update that information in this service.

You can use below annotation to change load balancer type and it is only supported on aws only.

service.beta.kubernetes.io/aws-load-balancer-type 
-- Rajesh Deshpande
Source: StackOverflow

2/13/2019

Because use are using minikube, I think it is safe to assume that this is for development environment. You always have the option to change the way a service is exposed. See kubernetes docs in service types section.

Now when you want to mimic the production in your dev env on the types of services, you have varied work arounds for this. Now because Minikube doesn't come bundled with LoadBalancer, you have to either install one (like MetalLB) in here or try workarounds/hacks as detailed in the blog post.

Hope that helps!

-- karthiks
Source: StackOverflow

2/5/2019

If you have later plan to attach domain do DNS mapping check this indirectly this will also make load balancer but handling request and other stuff is easy with it.

https://kubernetes.io/docs/concepts/services-networking/ingress/

You can use annotation to change load balancer type.

service.beta.kubernetes.io/aws-load-balancer-type

-- Harsh Manvar
Source: StackOverflow