【发布时间】:2021-12-21 10:33:09
【问题描述】:
我正在尝试将 GKE pod 连接到 mongodb Atlas。
我在 Atlas 和 GCP VPC 网络之间设置并激活了 VPC 对等网络连接,但我无法在 gcloud 终端或 GKE pod 上配置 mongosh 来测试我的连接。
我该怎么做?完全卡住了!
【问题讨论】:
标签: google-kubernetes-engine mongodb-atlas mongo-shell gke-networking
我正在尝试将 GKE pod 连接到 mongodb Atlas。
我在 Atlas 和 GCP VPC 网络之间设置并激活了 VPC 对等网络连接,但我无法在 gcloud 终端或 GKE pod 上配置 mongosh 来测试我的连接。
我该怎么做?完全卡住了!
【问题讨论】:
标签: google-kubernetes-engine mongodb-atlas mongo-shell gke-networking
要在您的 Cloud Shell 中安装 mongosh,您首先需要使用命令 lsb_release -dc 找出正在运行的操作系统;对于这个例子,运行的操作系统是“Debian GNU/Linux 10 (buster)”。在这里您可以找到有关如何在不同操作系统 [1] 上安装 mongodb 的文档。
这些是在 Debian 系统上安装 mongosh 社区版的步骤:
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -导入公钥
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt-get update
sudo apt-get install -y mongodb-mongosh
现在,对于在 GKE pod 上的安装,您有几个选择;首先,是使用命令kubectl exec -it pod-name -- /bin/bash 在您正在运行的 pod 中打开一个 bash 命令 shell,然后使用提供的步骤从那里安装 mongosh(这些可能因 pod 映像所基于的操作系统而异)。
第二个选项是在您的 pod [2] 中运行 mongodb docker 映像,该映像已经加载了运行 mongodb 所需的所有依赖项,包括 mongosh,在这种情况下,您只需要在您的 pod 中打开一个 bash 命令 shell 并测试。
【讨论】: