Neelam
Neelam

Reputation: 567

Cross namespace communication in Kubernetes

Is there any way to setup cross communication with different namespace, say pods of namespace-a to communicate pods of namespace-b with each other in GKE cluster except for setting network policies?

Upvotes: 3

Views: 5502

Answers (1)

Jonas
Jonas

Reputation: 128777

Networking within a Kubernetes cluster can be done in different ways, but the recommended and most common way is to use DNS names. Pods get their own DNS names, but it is recommended that you access another app in the cluster via the DNS name for the Service.

DNS names are hierarchical, starting with the Service name, and then the Namespace name.

  • To access another app in the same namespace, use <other-app-service-name>, e.g. http://<other-app-service-name>.

  • To send a request to an app in a different namespace, also use the namepspace part of the domain name, <another-app-service-name>.<other-namespace-name>, e.g. http://<another-app-service-name>.<other-namespace-name>

Upvotes: 8

Related Questions