mongodb - 如何从 mongodb compass gui 访问 azure kubernete pod mongodb 实例

标签 mongodb azure kubernetes-pod mongodb-compass

MongoDB 实例位于 Azure Kubernetes Pod 中。我想从外部安全地访问这个 headless mongodb。我已经在虚拟机中安装了 compass 并将连接字符串粘贴到 mongodb compass 中,VM 和 kubernete 都在同一网络中,但它显示 getaddrinfo ENOTFOUND 错误。在连接字符串中有副本集名称 rs0 和 ssl=false

最佳答案

什么是 headless 服务?

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/

您无法从另一个虚拟机连接到 AKS 中运行的 headless 服务。

您可以通过负载均衡器NodePort公开您的服务,并从另一个虚拟机进一步访问。

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.

引用号:https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer

或者您可以使用入口 Controller 将服务公开到集群之外并对其进行管理。

关于保护开放服务,如果使用入口 Controller ,您可以将 IP 列入白名单。

在入口级别将 IP 列入白名单:https://medium.com/@maninder.bindra/using-nginx-ingress-controller-to-restrict-access-by-ip-ip-whitelisting-for-a-service-deployed-to-bd5c86dc66d6

或者直接在服务中将 IP 范围列入白名单

loadBalancerSourceRanges:
  - "143.231.0.0/16"

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

关于mongodb - 如何从 mongodb compass gui 访问 azure kubernete pod mongodb 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71613608/

相关文章:

javascript - 在 Mongoose 外部的函数中返回数据

mongodb - 在opensuse上安装mongodb时出错

mongodb - 是否可以使用聚合框架对 MongoDB 中的 2 个字段求和?

c# - Azure函数.net 7升级问题: System. IO.FileNotFoundException : 'Could not load file or assembly ' Microsoft. Extensions.Http,<...>'

javascript - 如何使用 documentdb 编写复合 WHERE 条件?

linux - 定义环境变量,引用容器的可变环境[kubernetes]

docker - Hostpath 卷未安装在 Windows 的 Docker 桌面上运行的 kubernetes 上

javascript - 如何在 meteor 中响应式聚合 mongodb

c# - 根据消息元数据过滤 ServiceBusTrigger 消息

namespaces - Kubernetes - 由于 "No nodes are available that match all of the predicates: MatchInterPodAffinity (1)."导致 pod 调度失败