Kiramm
Kiramm

Reputation: 351

DNS for Pod in another Kubernetes cluster on GKE

I am trying to connect to the MongoDB replica set that is hosted in another Kubernetes cluster of the same GCP project. I want to use DNS names in the connection string.

I was able to connect to mongodb hosted in the same cluster using this connection string:

mongodb://<pod-name>.<service-name>.<namespace>.svc.cluster.local:27017,<pod-name>.<service-name>.<namespace>.svc.cluster.local:27017/?replicaSet=<rs-name>

So my question is:

Is it possible to use the DNS name to reference the pod in another cluster? I looked through this document and it states:

Any pods created by a Deployment or DaemonSet have the following DNS resolution available:

pod-ip-address.deployment-name.my-namespace.svc.cluster-domain.example.

But I am not sure what is the format of the cluster-domain.example part.

Upvotes: 1

Views: 326

Answers (1)

Arghya Sadhu
Arghya Sadhu

Reputation: 44549

You can not use Kubernetes Service DNS(CoreDNS) to access a pod from outside the kubernetes cluster even from another kubernetes cluster. You need to expose the mongodb pod via LoadBalancer(recommended) or NodePort type service and access it using LoadBalancer endpoint or NodeIP:NodePort from the other kubernetes cluster.

Upvotes: 2

Related Questions