Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes : Service shared between multiple namespaces

Tags:

kubernetes

I'm searching for the answer but i didn't find it anywhere. Is it possible to share a service between multiple namespaces ?

For instance, if i have 2 namespaces (let's say 'qa' and 'dev'), is it possible to use the same database server ? The database server would be preferably managed by kubernetes too.

I've read this issue : https://github.com/openshift/origin/issues/1244 But it's not directly related to kubernetes.

Regards, Smana

like image 305
Smana Avatar asked Sep 21 '15 08:09

Smana


People also ask

How do I access a service from a different namespace?

In order to access an application running in a different namespace, you need to add the namespace to the service name, as if it was its domain. For example, if your first namespace was named cindylopez , the same redis instance we accessed on the previous example would be available via redis.

How do I access Kubernetes service from another namespace?

In Kubernetes the namespace is used to isolate the resource, based on the use case services in different namespace may required to access the service located in another namespace and kubernetes allow this by using ExternalName concept.

Can namespaces talk to each other?

Namespaces are used to isolate resources within the control plane. For example if we were to deploy a pod in two different namespaces, an administrator running the “get pods” command may only see the pods in one of the namespaces. The pods could communicate with each other across namespaces however.

How do you communication between pods in different namespaces?

Allow two pods (say pod A and B) running in same/different namespace communicate irrespective of the protocol(say http,https,akka. tcp) along with a valid Network policy applied. Solutions tried: Tried applying network policy to both the pods and also used the service name: “my-svc.


1 Answers

Services are accessible from all namespaces as long as you address them using both the name and the namespace.

For example, if you have a service named db in namespace dev, you can access it using the DNS name db. While this won't work from qa, you can access it from both qa and dev if you instead use the DNS name db.dev (<service>.<namespace>), in order to clarify which namespace should be searched for the service.

like image 190
Alex Robinson Avatar answered Dec 06 '22 19:12

Alex Robinson