Skip to content
logo
Percona Operator for MySQL
Install on Minikube
Initializing search
    percona/k8sps-docs
    percona/k8sps-docs
    • Welcome
      • Design and architecture
      • Install with Helm
      • Install on Minikube
        • Prerequisites
        • Install the Operator and deploy your MySQL cluster
        • Verify the cluster operation
      • System Requirements
      • Install on Google Kubernetes Engine (GKE)
      • Install on Amazon Elastic Kubernetes Service (AWS EKS)
      • Generic Kubernetes installation
      • Backup and restore
      • Application and system users
      • Anti-affinity and tolerations
      • Labels and annotations
      • Changing MySQL Options
      • Exposing the cluster
      • Transport Encryption (TLS/SSL)
      • Telemetry
      • Horizontal and vertical scaling
      • Monitor with Percona Monitoring and Management (PMM)
      • Add sidecar containers
      • Monitor Kubernetes
      • Custom Resource options
      • Percona certified images
      • Copyright and licensing information
      • Trademark policy
      • Release notes index
      • Percona Operator for MySQL 0.5.0 (2023-03-30)
      • Percona Operator for MySQL 0.4.0 (2023-01-30)
      • Percona Operator for MySQL 0.3.0 (2022-09-29)
      • Percona Operator for MySQL 0.2.0 (2022-06-30)
      • Percona Distribution for MySQL Operator based on Percona Server for MySQL 0.1.0 (2022-01-25)

    • Prerequisites
    • Install the Operator and deploy your MySQL cluster
    • Verify the cluster operation

    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 or Hyper-V. Using it is a popular way to test the Kubernetes application locally prior to deploying it on a cloud.

    Prerequisites¶

    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.5.0 https://github.com/percona/percona-server-mysql-operator
      $ cd percona-server-mysql-operator
      
    2. Deploy the operator with the following command:

      $ kubectl apply -f deploy/bundle.yaml
      
      Expected output
      customresourcedefinition.apiextensions.k8s.io/perconaservermysqlbackups.ps.percona.com created
      customresourcedefinition.apiextensions.k8s.io/perconaservermysqlrestores.ps.percona.com created
      customresourcedefinition.apiextensions.k8s.io/perconaservermysqls.ps.percona.com created
      serviceaccount/percona-server-mysql-operator created
      role.rbac.authorization.k8s.io/percona-server-mysql-operator-leaderelection created
      role.rbac.authorization.k8s.io/percona-server-mysql-operator created
      rolebinding.rbac.authorization.k8s.io/percona-server-mysql-operator-leaderelection created
      rolebinding.rbac.authorization.k8s.io/percona-server-mysql-operator 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
      perconaservermysql.ps.percona.com/cluster1 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
      NAME       REPLICATION   ENDPOINT                   STATE   MYSQL   ORCHESTRATOR   HAPROXY   ROUTER   AGE
      cluster1   async         cluster1-haproxy.default   ready   3       3              3                  5m50s
      

      You can also track the progress via the Kubernetes dashboard:

      image

    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.

    1. You will need password for the root user to access the cluster. Use kubectl get secrets command to see the list of Secrets objects (by default the Secrets object you are interested in has cluster1-secrets name). Then kubectl get secret cluster1-secrets -o yaml command will return the YAML file with generated Secrets, including the root password, which should look as follows:

      ...
      data:
        ...
        root: MWV1VDdZSGxYWHNhcHpYTjF3Ug==
      

      Here the actual password is base64-encoded. Use echo 'MWV1VDdZSGxYWHNhcHpYTjF3Ug==' | base64 --decode command to bring it back to a human-readable form.

    2. 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
      

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

    3. Now run mysql tool in the percona-client command shell using the password obtained from the Secret instead of the <root password> placeholder:

      $ mysql -h cluster1-haproxy -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
      owners.
      
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
      
      mysql>
      

      The following example will use 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)
      
      mysql> 
      

    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 consulting services , contact Percona Sales.


    Last update: 2023-08-31
    Percona LLC and/or its affiliates, © 2009 - 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. Read more about Percona Cookie Policy.