Home > Net >  How to access azure kubernete pod mongodb instance from mongodb compass gui
How to access azure kubernete pod mongodb instance from mongodb compass gui

Time:03-25

MongoDB instance is in Azure Kubernetes pod. I want to access this headless mongodb from outside safely. I already installed compass in Virtual Machine and paste the connection string in mongodb compass both VM and kubernete are in same network but it is showing getaddrinfo ENOTFOUND error. In connection string there is replica set name rs0 and ssl=false

CodePudding user response:

What is headless service ?

With a Headless Service, clients can connect to it’s pods by connecting to the service’s DNS name. But using headless services, DNS returns the pod’s IPs and client can connect directly to the pods instead via the service proxy. read more : https://blog.knoldus.com/what-is-headless-service-setup-a-service-in-kubernetes/

From another VM you cannot connect to headless service running in your AKS.

You can expose your service with NodePort of Loadbalancer and further access from another VM.

NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting :.

LoadBalancer: Exposes the Service externally using a cloud provider's load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created.

Ref : https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer

Or else you can use the ingress controller to expose the service out of the cluster and manage it.

Regarding securing opening service you can whitelist the IP if using the ingress controller.

Whitelisting IP at ingress level: https://medium.com/@maninder.bindra/using-nginx-ingress-controller-to-restrict-access-by-ip-ip-whitelisting-for-a-service-deployed-to-bd5c86dc66d6

Or else whitelist IP ranges in Service directly

loadBalancerSourceRanges:
  - "143.231.0.0/16"

Reference : https://aws.amazon.com/premiumsupport/knowledge-center/eks-cidr-ip-address-loadbalancer/

  • Related