Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single service for multiple pods

I have 9 pods running which are basically 9 different applications.

Is it possible to have same k8s service (LB | Public IP) for multiple pods such that I can access them by different ports, but the same IP of service (LB)?

E.g. like so:
LB-IP:80 -- In the backend an application is running, which I can access.
LB-IP:8080 (Same IP as previous) -- I will run another pod in the backend.

**** Selectors will be different for each pod.**

like image 794
Saurabh Avatar asked Jan 12 '18 09:01

Saurabh


People also ask

Can a service have multiple pods?

As for the pure service approach, no it is not possible. Service relates to only one selector so you can't.

Can a microservice have multiple pods?

In a typical Kubernetes environment for a given microservice (or a container), we run multiple instances of the same Pod to address scalability requirements; each Pod in a Kubernetes cluster has multiple replicas.

Does every pod need a service?

Running a pod or deployment without a service is very possible, and in some cases it will be perfectly fine. If your workloads do not require communication with other resources either within or outside of the cluster there is no need to use a service.

How multiple pods communicate with each other?

A Pod can communicate with another Pod by directly addressing its IP address, but the recommended way is to use Services. A Service is a set of Pods, which can be reached by a single, fixed DNS name or IP address. In reality, most applications on Kubernetes use Services as a way to communicate with each other.


1 Answers

As for the pure service approach, no it is not possible. Service relates to only one selector so you can't.

Now, as you talk about LB here, you might be talking about exposing the thing externally, and for that you can have an Ingress/IngressController. If you want, you can also just deploy a "gateway" service that will do the thing for you (ie. HA proxy configured to expose these different ports you want)

If your environment does not support ingress, you might want to deploy ie. Nginx Ingress Controller which does a great job for the point of entry to your services

like image 93
Radek 'Goblin' Pieczonka Avatar answered Oct 09 '22 08:10

Radek 'Goblin' Pieczonka