Skip to content

Rate this page
Thanks for your feedback
Thank you! The feedback has been submitted.

Get free database assistance or contact our experts for personalized support.

Install Percona Server for MongoDB on Minikube

Installing the Percona Operator for MongoDB on Minikube is the easiest way to try it locally without a cloud provider. Minikube runs Kubernetes on GNU/Linux, Windows, or macOS system using a system-wide hypervisor, such as VirtualBox, KVM/QEMU, VMware Fusion or Hyper-V. Using it is a popular way to test Kubernetes application locally prior to deploying it on a cloud.

The following steps are needed to run Percona Operator for MongoDB on minikube:

  1. Install minikube , using a way recommended for your system. This includes the installation of the following three components:

    1. kubectl tool,

    2. a hypervisor, if it is not already installed,

    3. actual minikube package

    After the installation, run minikube start --memory=5120 --cpus=4 --disk-size=30g (parameters increase the virtual machine limits for the CPU cores, memory, and disk, to ensure stable work of the Operator). Being executed, this command will download needed virtualized images, then initialize and run the cluster. After Minikube is successfully started, you can optionally run the Kubernetes dashboard, which visually represents the state of your cluster. Executing minikube dashboard will start the dashboard and open it in your default web browser.

  2. Deploy the operator using the following command:

    kubectl apply --server-side -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.23.0/deploy/bundle.yaml
    
  3. Deploy MongoDB cluster with:

    kubectl apply -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.23.0/deploy/cr-minimal.yaml
    

    Note

    This deploys a one-shard MongoDB cluster with one replica set with one node, one mongos node and one config server node. The deploy/cr-minimal.yaml is for minimal non-production deployment. For more configuration options please see deploy/cr.yaml and Custom Resource Options. You can clone the repository with all manifests and source code by executing the following command:

    git clone -b v1.23.0 https://github.com/percona/percona-server-mongodb-operator
    

    After editing the needed options, apply your modified deploy/cr.yaml file as follows:

    kubectl apply -f deploy/cr.yaml
    

    The creation process may take some time.

    The process is over when both operator and replica set pod have reached their Running status. kubectl get pods output should look like this:

    You can also track the progress via the Kubernetes dashboard:

    image

Verifying the cluster operation

It may take ten minutes to get the cluster started. When kubectl get pods command finally shows you the cluster is ready, you can try to connect to the cluster.

To connect to Percona Server for MongoDB, use the connection string Secret that the Operator creates for the databaseAdmin user. This Secret is available starting with Operator version 1.23.0 and newer. For previous versions, refer to the Connect manually section.

  1. List the Secrets objects:

    kubectl get secrets -n <namespace>
    

    The connection string Secret is named minimal-cluster-databaseadmin-conn-str by default.

  2. Retrieve the connection string

    kubectl get secret <clusterName>-databaseadmin-conn-str -n <namespace> \
     -o jsonpath='{.data.databaseAdmin_mongos_connectionString}' | base64 --decode && echo
    
    kubectl get secret <clusterName>-databaseadmin-conn-str -n <namespace> \
    -o jsonpath='{.data.databaseAdmin_rs0_connectionStringSrv}' | base64 --decode && echo
    

    See Connection secrets for other available keys.

  3. Run a container with a MongoDB client and connect its console output to your terminal. The following command does this, naming the new Pod percona-client:

    kubectl run -i --rm --tty percona-client --image=percona/percona-server-mongodb:8.0.26-11 --restart=Never -- bash -il
    

    Executing it may require some time to deploy the corresponding Pod.

  4. Connect using the connection string from step 2:

    mongosh "<connection-string>"
    

Connect manually (alternative)

If you need to build a connection URI yourself, retrieve credentials from the user Secret and construct the URI.

  1. List the Secrets objects:

    kubectl get secrets -n <namespace>
    

    The Secrets object you are interested in has the <cluster-name>-secrets name. (For the cluster my-cluster-name, the Secret name is my-cluster-name-secrets).

  2. Retrieve the admin username and password:

    kubectl get secret <secret-name> -n <namespace> -o jsonpath='{.data.MONGODB_DATABASE_ADMIN_USER}' | base64 --decode && echo
    kubectl get secret <secret-name> -n <namespace> -o jsonpath='{.data.MONGODB_DATABASE_ADMIN_PASSWORD}' | base64 --decode && echo
    
  3. Run a container with a MongoDB client and connect its console output to your terminal. The following command does this, naming the new Pod percona-client:

    kubectl -n <namespace> run -i --rm --tty percona-client --image=percona/percona-server-mongodb:8.0.26-11 --restart=Never -- bash -il
    

    It may take some time to deploy the corresponding Pod.

  4. Now run mongosh tool inside the percona-client command shell using the admin user credentials you obtained from the Secret, and a proper namespace name instead of the <namespace name> placeholder. The command will look different depending on whether sharding is on (the default behavior) or off:

    mongosh "mongodb://databaseAdmin:databaseAdminPassword@my-cluster-name-mongos.<namespace name>.svc.cluster.local/admin?ssl=false"
    
    mongosh "mongodb+srv://databaseAdmin:databaseAdminPassword@my-cluster-name-rs0.<namespace name>.svc.cluster.local/admin?replicaSet=rs0&ssl=false"
    

Last update: July 23, 2026
Created: July 23, 2026