Multiple deployments to a single service

My backend has 5 different deployments, each serving the request in a specific port.

Frontend service contacts the backend service with the necessary details. The backend service should be able to decide the required pod (from one of the 5 deployments) to serve the request.

Instead of creating 5 different services, is it possible to link a single service to multiple deployments?

Kubernetes version: 1.12
Cloud being used: Amazon EKS

PS: My requirement is different from https://github.com/kubernetes/kubernetes/issues/24875

Services use selectors and labels to target pods. If all your pods have the same label and the service targets that label; they will be included in that service.

With that said – you won’t be able to map specific ports to specific pods and it’s likely the application level routing will fail. A service will load-balance across all pods in the service and you won’t be able to do more granular routing.

You might want to take a look at some of the service mesh offerings like linkerd and istio that can do more granular control like that.

Very well described situations by @mrbobbytables , You need to do away with VM based EKS. For better management either you need to get those service mesh or you need to switch to native container based cloud which will provide deep granularity also your devops will be much simpler.

P.S - I was on AWS an year back and had shift away due to many advance issue in devops, including this one.

I’m trying to implement istio for service mesh. Basically, I’m planning to introduce a VirtualService on top of 5 different backend services (in my actual question) and to access it from the Frontend service.

Is it possible to expose istio’s VirtualService to kubernetes’ Service?
Or should I include the frontend service also inside the VirtualService along with the Gateway?


rajavinoth

    September 26

I’m trying to implement istio for service mesh. Basically, I’m planning to introduce a VirtualService on top of 5 different backend services (in my actual question) and to access it from the Frontend service.

Is it possible to expose istio’s VirtualService to kubernetes’ Service?

I don’t quite understand the question. Typically a VirtualService represents a hostname (HTTP host header) or IP address to which your custom processing applies (e.g. URL Path matching). Any client who is sidecar-enabled and ties to access that hostname or IP should automatically be routed through that custom processing.

I need to access the VirtualService (of Istio) from Kubernetes Service
Could you tell me how to achieve this (if its possible)

I am not sure if following would work but will try if i have a requirement like what whay you have

  1. As part of deployment, create one replica for each having different targeports and make sure to have same labels(say XYZ) for all of them.
  2. Create a service that uses XYZ to choose endpoints.
  3. Now check the proxy you have(iptables or ipvs) picks up different port

I found this on stackoverflow.

The accepted answer (also written by OP) shows a way to have multiple deployments to a single service and communicating with their cluterIPs.

Not sure if this would meet your requirements but found it interesting.