Skip to content

Instantly share code, notes, and snippets.

@HarshadRanganathan
Created December 1, 2021 22:55
Show Gist options
  • Save HarshadRanganathan/2669b379d8251d5580f1b99ed970a597 to your computer and use it in GitHub Desktop.
Save HarshadRanganathan/2669b379d8251d5580f1b99ed970a597 to your computer and use it in GitHub Desktop.
Kubernetes Jump Pod for MongoDB

[1] Create Ubuntu Pod

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: ubuntu
  labels:
    app: ubuntu
spec:
  containers:
  - name: ubuntu
    image: ubuntu:latest
    command: ["/bin/sleep", "3650d"]
    imagePullPolicy: IfNotPresent
  restartPolicy: Always
EOF

[2] Run below commands inside the Pod

apt-get update

apt-get install wget

apt-get install gnupg

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add -

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-5.0.list

apt-get update

apt-get install -y mongodb-org

[3] In the interactive prompt, answer the questions as below:

Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the
time zones in which they are located.

  1. Africa  2. America  3. Antarctica  4. Australia  5. Arctic  6. Asia  7. Atlantic  8. Europe  9. Indian  10. Pacific  11. SystemV  12. US  13. Etc
Geographic area: Etc

Please select the city or region corresponding to your time zone.

  1. GMT    4. GMT+10  7. GMT+2  10. GMT+5  13. GMT+8  16. GMT-1   19. GMT-12  22. GMT-2  25. GMT-5  28. GMT-8  31. Greenwich  34. Universal
  2. GMT+0  5. GMT+11  8. GMT+3  11. GMT+6  14. GMT+9  17. GMT-10  20. GMT-13  23. GMT-3  26. GMT-6  29. GMT-9  32. UCT        35. Zulu
  3. GMT+1  6. GMT+12  9. GMT+4  12. GMT+7  15. GMT-0  18. GMT-11  21. GMT-14  24. GMT-4  27. GMT-7  30. GMT0   33. UTC
Time zone: 33

[4] Connect to MongoDB

$ mongosh mongodb://<url>:27017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment