Search code examples
mongodbmean-stackkubernetes

Access to Mongodb in Kubernetes


I created a Mongodb service according to the Kubernetes tutorial.

Now my question is how do I gain access to the database itself, with a client like Robomongo or similar clients? Just for making backups or exploring what data have been entered.

The mongo-pod and service only have an internal endpoint, and a single mount.

Is there any way to safely access this instance with no public endpoint?

Internally URI is mongo:27***


Solution

  • The kubernetes cmd-line tool provides this functionality as @ainlolcat stated

    kubectl get pods
    

    Retrieves the pod names currently running and with:

    kubectl exec -i mongo-controller-* bash
    

    you get a basic bash, which lets you execute

    mongo
    

    to get into the database to create dumps, and so on. The bash is very basic and has no features like completion and so on. I have not found a solution for better shell but it does the job