Invictus
Invictus

Reputation: 2780

Kubernetes: Can a single K8s POD host 2 or more K8s services

I am new to kubernetes, just wanted to know if my question is valid.

I had a question if a single POD can host 2 or more services.

And If it can host multiple services, how can it differentiate the traffic between the services.

Does it do a PORT mapping.

Please, let me know.

Upvotes: 6

Views: 8540

Answers (1)

sanche
sanche

Reputation: 181

You can add multiple containers to the same pod, but that's only recommended if the services are tightly coupled, like if they need to communicate. For example, if you have a web server and a sql database, you would likely want them in the same pod.

If the services are distinct, you would likely want to put them in different pods, but deploy them to the same cluster of nodes. Then, you can have a LoadBalancer service on the cluster that can route different ports or paths to the right pod. In this way, the services can be scaled and managed separately (and without worrying about port conflicts), but they still draw from the same pool of resources

Upvotes: 3

Related Questions