Openshift - calling another API within same namespace

6/14/2020

I have an two container in same namespace. Service-A & Service-B.

And in my case, i want to talk to Service-B from Service-A. Through RestTemplate, i am making post call for communication like below.

public Response fetchData(Request request) {
   return restTemplate.postForEntity("http://Service-B:8080/api", request, Response.class).getBody();
}

It is working fine in my lower region as i have only one POD for Service-B. My doubt here is, if i have more PODS (lets say three POD) in Production for handling load. Will the load balancing happen between PODS, if i use service url instead of router url?

-- Mohan
kubernetes
kubernetes-pod
openshift
rest
spring-resttemplate

1 Answer

6/14/2020

If using kubernetes service then kube-proxy component provides load balancing at L4 layer via linux iptables.

Kube proxy running in IPVS mode provides least conns, locality, weighted, persistence based load balancing

Kube proxy running in userspace or iptables mode provides round robin load balancing

But if you need advanced loadbalancing at L7 layer then you need to use ingress or router.

https://kubernetes.io/docs/concepts/services-networking/#the-gory-details-of-virtual-ips

-- Arghya Sadhu
Source: StackOverflow