Install Percona XtraDB Cluster on Minikube

Installing the PXC 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 the Kubernetes application locally prior to deploying it on a cloud.

The following steps are needed to run PXC Operator on Minikube:

  1. Install Minikube, using a way recommended for your system. This includes the installation of the following three components: #. kubectl tool, #. a hypervisor, if it is not already installed, #. actual Minikube package

    After the installation running minikube start should 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-xtradb-cluster-operator repository:

    git clone -b release-1.3.0
    cd percona-xtradb-cluster-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 pxc and proxysql sections:

    1. comment resources.requests.memory and resources.requests.cpu keys (this will fit the Operator in minikube default limitations)
    2. set 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 XtraDB Cluster as a one-node cluster).

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

    kubectl apply -f deploy/cr.yaml
  6. During previous steps, the Operator has generated several secrets, including the password for the root user, which you will definitely 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-secrets name). Then kubectl get secret my-cluster-secrets -o yaml will return the YAML file with generated secrets, including the root password which should look as follows:

      root: cm9vdF9wYXNzd29yZA==

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

  7. Check connectivity to a newly created cluster.

    First of all, run percona-client and connect its console output to your terminal (running it may require some time to deploy the correspondent Pod):

    kubectl run -i --rm --tty percona-client --image=percona:5.7 --restart=Never -- bash -il

    Now run mysql tool in the percona-client command shell using the password obtained from the secret:

    mysql -h cluster1-proxysql -uroot -proot_password

Previous topic

Install Percona XtraDB Cluster on OpenShift

Next topic

Scale Percona XtraDB Cluster on Kubernetes and OpenShift