<p>I have a kubernetes cluster with serviceA on namespaceA and serviceB on namespaceB.</p>

<p>I want, from serviceA, use kubernetes service discovery to programmatically list serviceB.
I am planning to use <a href="https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/2.1.0.RC1/single/spring-cloud-kubernetes.html#_discoveryclient_for_kubernetes" rel="nofollow noreferrer">spring cloud kubernetes</a> ( @EnableDiscoveryClient ).</p>

<p>However, there is a company wide policy to block the use of the configuration below that should have solved the problem:
<code>spring.cloud.kubernetes.discovery.all-namespaces=true</code></p>

<p>Is there any way to circumvent the problem? Maybe assign serviceB to two different namespaces or some other permission/configuration that I am not aware of?</p>

guilhermecgs
<p>If you are trying to simply look up a service IP by service name through Kubernetes API than it should not really matter if you're doing it through <code>kubectl</code> or a Java client, the options you pass to the API are the same. </p>

<p>The thing that matters however is whether the service name would be looked up in the same namespace only or in all namespaces.  Accessing a service from a different namespace can be done by specifying its name along with the namespace - instead of <code>my-service</code> they would need to write <code>my-service.some-namespace</code>.</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#headless-services" rel="nofollow noreferrer">Services without selectors</a> are also an option to expose a service from one namespace to another so that the namespace would be specified in Kubernetes objects and not in app code.</p>

<p>Please let me know if that helps.</p>
