How does deploying in different Kubernetes namespaces affect pod-to-pod communication?

7/16/2020

I have been deploying in Kubernetes Default namespace and it has been well. However, i now started deploying in different namespaces ie: Development & Production. So my questions is:

Does deployment in different namespaces of kubernetes affect communication between pods which initially have been communicating according to configured firewalls?

currently, these are my namespaces:

trevor@deployment-node:~$ kubectl get namespace
NAME              STATUS   AGE
default           Active   43d
development       Active   13s
kube-node-lease   Active   43d
kube-public       Active   43d
kube-system       Active   43d
test              Active   13d
-- Trevor Nathan
containers
gke-networking
kubernetes
namespaces

1 Answer

7/16/2020

You can put the Pods behind Services.it creates a corresponding DNS entry. This entry is of the form <service-name>.<namespace-name>.svc.cluster.local, which means that if a container just uses <service-name>, it will resolve to the service which is local to a namespace.

if you want to reach across namespaces, you need to use the fully qualified domain name (FQDN).

<service-name>.<service-namespace>.svc.cluster.local

Normally, you just need the Service’s name and DNS will automatically resolve to the full address. However, if you need to access a Service in another Namespace just use the Service name plus the Namespace name.

For example, if you want to connect to the database service in the test namespace, you can use the following address:

database.test

Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#namespaces-and-dns https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-organizing-with-namespaces

-- hoque
Source: StackOverflow