I have a Kubernetes cluster with two namespaces, dbns
(where a database lives) and jobland
(where jobs run from).
I would like to run a Job
from a container running in the jobland
namespace that will connect to and run scripts against a DB living in the dbns
namespace.
When I run get pod,statefulset,svc,configmap -o wide
I see that my DB has an IP of 10.1.0.34
, but I'm assuming thats only "reachable" from other containers running inside the dbns
namespace, correct? If so, how could I expose its IP so that items from outside the dbns
namespace can connect to it (such as something running in jobland
)?
CodePudding user response:
If you are exposing your objects (pods, deployments, etc) using a K8S service you can expose them outside namespaces with an IP or with FQDN
Here is an example of how to do it:
The name (FQDN) will be the same regardless of the IP and cluster which your code are deployed to.