If you have kubectl access but no UI access or area already logged in to kubectl and want to run a mongo query you can use the following:
4.X Command Line Connection Example
The mongo client and mongodump commands are available in the mongo-replicaset container. Here are some sample commands for navigating.
-
Find the service:
kubectl get svc --all-namespaces -l app.kubernetes.io/name=mongodb-replicaset
-
Describe the service to get endpoint IPs:
kubectl describe svc --all-namespaces -l app.kubernetes.io/name=mongodb-replicaset
-
Find mongo secrets:
kubectl get secret --all-namespaces | grep mongo-replicaset-admin
-
Retrieve credentials:
kubectl get secret -n <domino-platform-namespace> mongodb-replicaset-admin -o yaml
-
Decode strings from secrets yaml:
1echo <user> | base64 --decode; echo; echo <password> | base64 --decode
-
Connect into the replicaset pod:
kubectl exec -it -n <domino-platform-namespace> mongodb-replicaset-0 bash
- Connect to db to run commands:
mongo --username admin
8. Access domino database
use domino
Comments
0 comments
Please sign in to leave a comment.