This is what I understood as the communication that happens within a Kubernetes cluster.
Different Containers can run within a Pod & multiple such Pods can run within a Node where a local network and hardware resources are shared within a Node. The communication point where a Pod listens on is the TargetPort
. Other Pods can communicate within a Cluster using the specific Port
. After a particular Deployment is exposed as a Service, the external communication (within the Localhost) occurs through the NodePort
.
So, does this mean that by exposing a deployment as a Service, it is running on the specific port no on the localhost or does it always need port forwarding to be done?
And once the service sent a request through the NodePort, it is mapped to the Port in order to get into the Cluster and then to the specific Target Port so that the request can reach a specific Pod. Is this communication flow correct?
It would be helpful if anyone could confirm whether my understanding is correct or point out any mistakes in the above. Thanks in advance.
CodePudding user response:
Attaching similar stack solutions SO1 and SO2 , SO3 will give you clarification on connectivity between Target port, Port and Node Port and Communication flow.