Reputation: 49
We have 2 namespaces, say namespace1 and namespace2.
The following are the services in namespace1 and the services exposed.
[root@console ~]# oc get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
config-server ClusterIP 172.30.8.152 <none> 8888/TCP 3h
eureka-server ClusterIP 172.30.120.74 <none> 8761/TCP 3h
expedia-rapidapi-service ClusterIP 172.30.236.3 <none> 8233/TCP 3h
travelcodes-service ClusterIP 172.30.14.36 <none> 8084/TCP 3h
tti-service ClusterIP 172.30.46.212 <none> 8245/TCP 2h
I can use nslookup lookup the cluster IP in any pod to the service "travelcodes-service"
/ $ nslookup travelcodes-service.contents.svc.cluster.local
Name: travelcodes-service.contents.svc.cluster.local
Address 1: 172.30.14.36 travelcodes-service.contents.svc.cluster.local
However, I can only use curl to access travelcodes-service if the pod is in namespace1 but not namespace2
curl 172.30.14.36:8084/ping
Is there anything I need to expose in order to let a pod in namespace2 to access "travelcodes-service" in namespace1?
Upvotes: 3
Views: 2460
Reputation: 21
You can access the service in with
<service1>.<namespace1>
For example you can use this url:
http://<service1>.<namespace1>.svc.cluster.local
More on that: DNS for Services and Pods
To get a list of all your namespaces:
oc get ns
And for a list of services in one namespace:
oc get services -n <namespace-name>
Upvotes: 2