If all the pods in all namespaces of a single cluster are on the same network, then how the pod’s with the same service name communicate with each other.
E.g I have Pod A and Pod B in both the namespaces in the same cluster, then how Pod A will know which pod B to communicate as both the namespace has pod B with the same service name.
@Vikki Long story short when trying to reach a service using it’s short name, a pod will look it up only in it’s own namespace, not across all namespaces in the cluster. So to answer your question: each Pod A will only talk to it’s “local” Pod B.
For a Pod A in one namespace to reach a Pod B in another namespace, you will need to use the fqdn of the service in ns2 which would be something like: <service-name>.<service-namespace>.svc.cluster.local
.
Thanks for update.
But recently i have install pods of hazelcast in both the namespace, but Hazelcast-mancenter is able to see all the pods in the other namespace also.
What is Hazelcast-mancenter?
It is used to monitor hazelcast and application pods
@Vikki I think there might be a bit of mix-up here…
That is perfectly normal. By default pods in the same cluster (on the same pod network) can can ping and ‘see’ each other.
Correct me if I am wrong, your initial post was about how a pod would know where to send traffic when using a service name if that name happened to exists in more than one namespace, correct ?
@madkonix thanks for help.
I just want to confirm that each namespace has separate network, or there is only one network for entire cluster.
@Vikki My pleasure.
By default a namespace doesn’t come with a specific network for the pods it will contain.
That is not always the case either and depends entirely on whether there are multiple pod cidr defined in the cluster or a single one.
Long story short if you have a single pod cidr in the cluster, all your pods will be in the same subnet. And if there are more than one, you might have pods in different subnets.
However keep in mind that having multiple cidrs does not automatically mean pods in one subnet won’t be able to reach pods in another subnet. As documented here, the default behaviour in a cluster is that pods on a node can communicate with all pods on all nodes without NAT
.
What if we have a private cluster with multiple namespace, is communication between node1-pod1-ns1 communicate to node2-pod2-ns2 and all pods are in different zone.