Mapping ports in Kubernetes Mapping ports in Kubernetes kubernetes kubernetes

Mapping ports in Kubernetes


Thanks for the very detailed setup, but I still have some questions.

1) When you say "Container" {A,B,C} do you mean Pod? Or are A, B, C containers in the same Pod?

2) "Container B utilises incoming port 8081 to talk to Container A and C" - What do you mean that it uses an INcoming port to talk to other containers? Who opens the connection, to whom, and on what destination port?

3) "needs to access the external database on port 3306" but later "needs to be able to be reached from an external system on port 3306" - Does B access an external database or is it serving a database on 3306?

I'm confused on where traffic is coming in and where it is going out in this explanation.

In general, you should avoid thinking in terms of nodes and you should avoid thinking about pods talking to pods (or containers to containers). You have some number of Services, each of which is backed by some number of Pods. Client pods (usually) talk to Services. Services receive traffic on a port and send that traffic to the corresponding targetPort on Pods. Pods receive traffic on a containerPort.

None of that requires hostPorts or nodePorts. The last question is which of these Services need to be accessed from outside the cluster, and what is your environment capable of wrt load-balancing.

If you answer this far, then I can come back for round 2 :)