Kubernetes load balancing

5/3/2019

I'm studing Kubernetes (with no regard of a specific Cloud Provider) and it's not so clear if the most generic Service (not the Service of type Load-Balancer) works as an internal load balancer among the various replicas of a single microservice.

So how to implement internal load balancing among replicas without exposing the microservice to the outside traffic?

-- Alex Mawashi
cloud
kubernetes
load-balancing
minikube

2 Answers

5/3/2019

You can use kubernetes service object which is top of the pod.

Service object manage the connection and traffic it can be also used as internal load balancer.

You can create service with yaml file

kind: Service
apiVersion: v1
metadata:
  name: myapp-service
spec:
  selector:
    app: Myapp
  ports:
  - port: 80
    targetPort: 9376

On the base of the same selector in pod metadata to divert the traffic to that pods. Just use proper selector in specs section inside service and pods.

-- Harsh Manvar
Source: StackOverflow

5/3/2019

in order to create an internal load balancer , you will need to create a service based on selectors in order to find the correct pod to direct the traffic.

in order for the pod to be blocked for outside traffic it should be of type ClusterIP.

-- eran meiri
Source: StackOverflow