I'm trying to connect a GKE pod to mongodb Atlas.
I have a VPC Peering Network connection set up and Active between Atlas and a GCP VPC Network, but I can't configure mongosh either in the gcloud terminal or on a GKE pod to test my connection.
How do I do this? Completely stuck!
To install mongosh in your Cloud Shell you need first to find out which Operating System is running with the command lsb_release -dc
; for this example the running OS is "Debian GNU/Linux 10 (buster)". Here you can find the documentation about how to install mongodb on the different Operating Systems [1].
These are the steps to install mongosh community edition on a Debian system:
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
Now, for the installation on a GKE pod you have a couple of options here; the first, is to open a bash command shell in your running pod with the command kubectl exec -it pod-name -- /bin/bash
and from there install mongosh with the provided steps (these can vary depending on the operating system the pod image is based on).
The second option is to run a mongodb docker image in your pod [2], which is already loaded with all the dependencies needed to run mongodb, including mongosh, in this case you would only need to open a bash command shell in your pod and test.