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:
Install minikube, using a way recommended for your system. This includes the installation of the following three components:
a hypervisor, if it is not already installed,
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 dashboardwill start the dashboard and open it in your default web browser.
Deploy the operator using the following command:
$ kubectl apply -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.13.0/deploy/bundle.yaml
Deploy MongoDB cluster with:
$ kubectl apply -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.13.0/deploy/cr-minimal.yaml
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.13.0 https://github.com/percona/percona-server-mongodb-operator
After editing the needed options, apply your modified
deploy/cr.yamlfile 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 podsoutput should look like this:
NAME READY STATUS RESTARTS AGE percona-server-mongodb-operator-d859b69b6-t44vk 1/1 Running 0 50s minimal-cluster-cfg-0 1/1 Running 0 41s minimal-cluster-mongos-0 1/1 Running 0 36s minimal-cluster-rs0-0 1/1 Running 0 39s
You can also track the progress via the Kubernetes dashboard:
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 secretsto see the list of Secrets objects (by default Secrets object you are interested in has
kubectl get secret minimal-cluster-name-secrets -o yamlwill return the YAML file with generated secrets, including the
MONGODB_USER_ADMIN_PASSWORDstrings, which should look as follows:
... data: ... MONGODB_USER_ADMIN_PASSWORD: aDAzQ0pCY3NSWEZ2ZUIzS1I= MONGODB_USER_ADMIN_USER: dXNlckFkbWlu
Here the actual login name and password are base64-encoded, and
echo 'aDAzQ0pCY3NSWEZ2ZUIzS1I=' | base64 --decodewill bring it back to a human-readable form.
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
$ kubectl run -i --rm --tty percona-client --image=percona/percona-server-mongodb:4.4.16-16 --restart=Never -- bash -il
Executing it may require some time to deploy the correspondent Pod. Now run
mongotool in the percona-client command shell using the login (which is
userAdmin) and password obtained from the secret:
$ mongo "mongodb://userAdmin:userAdmin123456@minimal-cluster-name-mongos.default.svc.cluster.local/admin?ssl=false"