Ping api in kubernetes environment which is running in other namespaces

11/21/2019

How do I ping my api which is running in kubernetes environment in other namespace rather than default. Lets say I have pods running in 3 namespaces - default, dev, prod. I have ingress load balancer installed and configured the routing. I have no problem in accessing default namespace - https://localhost/myendpoint.... But how do I access the apis that are running different image versions in other namespaces eg dev or prod? Do I need to add additional configuration in service or ingress-service files?

EDIT: my pods are restful apis that communicates over http requests. All I’m asking how to access my pod which runs in other namespace rather than default. The deployments communicate between each other with no problem. Let’s say I have a front end application running and want to access it from the browser, how is it done? I can access if the pods are in the default namespace by hitting http://localhost/path... but if I delete all the pods from default namespace and move all the services and deoloyments into dev namespace, I cannot access it anymore from the browser with the same url. Does it have a specific path for different namespaces like http://localhost/dev/path? Do I need to cinfigure it

Hopefully it's clear enough. Thank you

-- Vinod T Kumar
kubernetes
kubernetes-ingress
kubernetes-pod

1 Answer

11/21/2019

Route traffic with Ingress to Service

When you want to route request from external clients, via Ingress to a Service, you should put the Ingress and Service object in the same namespace. I recommend to use different domains in your Ingress for the environments.

Route traffic from Service to Service

When you want to route traffic from a pod in your cluster to a Service, possible in another namespace, it is easiest to use Service Discovery with DNS, e.g. send request to:

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

this is most likely

<service-name>.<namespace>.svc.cluster.local
-- Jonas
Source: StackOverflow