I like to understand.
Let`s say we have service1 and pod1 on node1 and service2 and pod2 on node2.Service 1 listen on port 80 and service 2 on port 81.Nodeport is 100 on node1 and 101 on node2.
target port 200 on pod1 and 202 on pod2.
how po1 comunicate with pod2?
pod 1 use ip-node2:101 to reach pod2?
You seem to be a little confused. TargetPort and listen port are the same (or should be if you want it to work) and service NodePorts are present on all nodes.
Check this out and see if it helps?
From what i seen,there is an nodeport running on any worker.
any pod from a worker reach any pod from other worker using internal clusterip.In this case the nodeport service is not used.
Then a pod from a worker reach any pod from other worker using ip.No port,targetport needed.
ex.an application client from a docker in pod send request on other docker on other pod from a different worker -where this target docker application listen on port and has pod ip.
Or a pod from a worker must use a port of nodeport service on other worker to reach the pod on that worker.
if this is true than a pod will reach other pod on other worker using the worker ip and the port of nodeport.
which is correct?
Pods should be able to talk to other pods directly, regardless of node.
then i not understood well.
" Port** exposes the Kubernetes service on the specified port within the cluster. Other pods within the cluster can communicate with this server on the specified port."
from Using Kubernetes Port, TargetPort, and NodePort – BMC Software | Blogs
A service (except for headless Service) has a virtual IP with a virtual port. When pods are talking to each other directly, they use the port that the pod exposes and listens on. When pods are talking to a service VIP it can use the virtual port number - which can be the same as the real port or not.
then any pod from a worker will talk to any pod from other worker -they use clusterip service.
pod1 from worker1 ->clusterip node2->pod2