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.**
As for the pure service approach, no it is not possible. Service relates to only one selector so you can't.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With