Install Percona Server for MongoDB on Minikube

Installing the Percona Server for MongoDB Operator 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 Server for MongoDB Operator 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. Clone the percona-server-mongodb-operator repository:

    git clone -b v1.6.0
    cd percona-server-mongodb-operator
  3. Deploy the operator with the following command:

    kubectl apply -f deploy/bundle.yaml
  4. Because minikube runs locally, the default deploy/cr.yaml file should be edited to adapt the Operator for the the local installation with limited resources. Change the following keys in the replsets section:

    1. comment all occurrences of the resources.requests.memory and resources.requests.cpu keys (this will fit the Operator in minikube default limitations)
    2. set all occurrences of the affinity.antiAffinityTopologyKey key to "none" (the Operator will be unable to spread the cluster on several nodes)

    Also, switch allowUnsafeConfigurations key to true (this option turns off the Operator’s control over the cluster configuration, making it possible to deploy Percona Server for MongoDB as a one-node cluster).

  5. Now apply the deploy/cr.yaml file with the following command:

    kubectl apply -f deploy/cr.yaml

    The creation process may take some time. The process is over when all Pods have reached their Running status. You can check it with the following command:

    kubectl get pods

    The result should look as follows:

    NAME                                               READY   STATUS    RESTARTS   AGE
    my-cluster-name-cfg-0                              2/2     Running   0          11m
    my-cluster-name-cfg-1                              2/2     Running   1          10m
    my-cluster-name-cfg-2                              2/2     Running   1          9m
    my-cluster-name-mongos-55659468f7-2kvc2            1/1     Running   0          11m
    my-cluster-name-mongos-55659468f7-7jfqc            1/1     Running   0          11m
    my-cluster-name-mongos-55659468f7-dfwcj            1/1     Running   0          11m
    my-cluster-name-rs0-0                              2/2     Running   0          11m
    my-cluster-name-rs0-1                              2/2     Running   0          10m
    my-cluster-name-rs0-2                              2/2     Running   0          9m
    percona-server-mongodb-operator-6fc78d686d-26hdz   1/1     Running   0          37m
  6. During previous steps, the Operator has generated several secrets, including the password for the admin user, which you will need to access the cluster. Use kubectl get secrets to see the list of Secrets objects (by default Secrets object you are interested in has my-cluster-name-secrets name). Then kubectl get secret my-cluster-name-secrets -o yaml will return the YAML file with generated secrets, including the MONGODB_USER_ADMIN and MONGODB_USER_ADMIN_PASSWORD strings, which should look as follows:


    Here the actual login name and password are base64-encoded, and echo 'aDAzQ0pCY3NSWEZ2ZUIzS1I=' | base64 --decode will bring it back to a human-readable form.

  7. Check connectivity to a newly created cluster.

    First of all, run a container with a MongoDB client and connect its console output to your terminal. The following command will do this, naming the new Pod percona-client:

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

    Executing it may require some time to deploy the correspondent Pod. Now run mongo tool in the percona-client command shell using the login (which is userAdmin) and password obtained from the secret:

    mongo "mongodb://userAdmin:userAdminPassword@my-cluster-name-mongos.default.svc.cluster.local/admin?ssl=false"

Previous topic

Design overview

Next topic

Install Percona server for MongoDB on Google Kubernetes Engine (GKE)

Contact Us

For free technical help, visit the Percona Community Forum.
To report bugs or submit feature requests, open a JIRA ticket.
For paid support and managed or professional services, contact Percona Sales.