Skip to content

Install Percona Server for MySQL on Minikube

Installing the Percona Operator for MySQL 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, Hyper-V or even Docker itself. Using it is a popular way to test the Kubernetes application locally prior to deploying it on a cloud.


To run Percona Operator for MySQL on Minikube you should first of all 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=4096 --cpus=3 (parameters increase the virtual machine limits for the CPU cores and memory, 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.

Install the Operator and deploy your MySQL cluster

  1. Clone the percona-server-mysql-operator repository:

    $ git clone -b v0.8.0
    $ cd percona-server-mysql-operator
  2. Deploy the operator with the following command:

    $ kubectl apply -f deploy/bundle.yaml
    Expected output created created created
    serviceaccount/percona-server-mysql-operator created created created created created
    configmap/percona-server-mysql-operator-config created
    deployment.apps/percona-server-mysql-operator created
  3. Because minikube runs locally, the Operator will be unable to spread the cluster on several nodes. Therefore default deploy/cr.yaml file should be edited to adapt the Operator for the installation on a single computer. Set all occasions of the antiAffinityTopologyKey key to "none". When done, apply the updated deploy/cr.yaml file with the following command:

    $ kubectl apply -f deploy/cr.yaml
    Expected output created

    This deploys three Percona Server for MySQL instances and one Orchestrator instance. For more configuration options please see deploy/cr.yaml and Custom Resource Options.

    The creation process may take some time. When the process is over your cluster will obtain the ready status. You can check it with the following command:

    $ kubectl get ps
    Expected output
    cluster1   async         cluster1-haproxy.default   ready   3       3              3                  5m50s

    You can also track the progress via the Kubernetes dashboard:


Verify the cluster operation

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

To connect to Percona Server for MySQL you will need the password for the root user. Passwords are stored in the Secrets object, which was generated during the previous steps.

Here’s how to get it:

  1. List the Secrets objects.

    $ kubectl get secrets
    It will show you the list of Secrets objects (by default the Secrets object you are interested in has cluster1-secrets name).

  2. Use the following command to get the password of the root user. Substitute cluster1 with your value, if needed:

    $ kubectl get secret cluster1-secrets -o yaml

    The command returns the YAML file with generated Secrets, including the root password, which should look as follows:

      root: <base64-encoded-password>
  3. The actual password is base64-encoded. Use the following command to bring it back to a human-readable form:

    $ echo '<base64-encoded-password>' | base64 --decode
  4. Run a container with mysql tool 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:8.0 --restart=Never -- bash -il

    It may require some time to execute the command and deploy the correspondent Pod.

  5. Now run mysql tool in the percona-client command shell using the password obtained from the Secret instead of the <root password> placeholder. The command will look different depending on whether the cluster uses load balancing with HAProxy (the default behavior) or uses MySQL Router (can be used with Group Replication clusters):

    $ mysql -h cluster1-haproxy -uroot -p<root password>
    $ mysql -h cluster1-router -uroot -p<root password>
    Expected output
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4065
    Server version: 8.0.29-21 Percona Server (GPL), Release 21, Revision c59f87d2854
    Copyright (c) 2009-2022 Percona LLC and/or its affiliates
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    The following example uses the MySQL prompt to check the max_connections variable:

    mysql> SHOW VARIABLES LIKE "max_connections";
    Expected output
    | Variable_name   | Value |
    | max_connections | 158   |
    1 row in set (0.02 sec)

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services. Join K8S Squad to benefit from early access to features and “ask me anything” sessions with the Experts.

Last update: 2024-07-16