Skip to content

Install Percona Distribution for MySQL on Amazon Elastic Kubernetes Service (EKS)

This guide shows you how to deploy Percona Operator for MySQL on Amazon Elastic Kubernetes Service (EKS). The document assumes some experience with Amazon EKS. For more information on the EKS, see the Amazon EKS official documentation .

Prerequisites

The following tools are used in this guide and therefore should be preinstalled:

  1. AWS Command Line Interface (AWS CLI) for interacting with the different parts of AWS. You can install it following the official installation instructions for your system .

  2. eksctl to simplify cluster creation on EKS. It can be installed along its installation notes on GitHub .

  3. kubectl to manage and deploy applications on Kubernetes. Install it following the official installation instructions .

Also, you need to configure AWS CLI with your credentials according to the official guide .

Create the EKS cluster

  1. To create your cluster, you will need the following data:

    • name of your EKS cluster,
    • AWS region in which you wish to deploy your cluster,
    • the amount of nodes you would like tho have,
    • the desired ratio between on-demand and spot instances in the total number of nodes.

    Note

    spot instances are not recommended for production environment, but may be useful e.g. for testing purposes.

    After you have settled all the needed details, create your EKS cluster following the official cluster creation instructions .

  2. After you have created the EKS cluster, you also need to install the Amazon EBS CSI driver on your cluster. See the official documentation on adding it as an Amazon EKS add-on.

Install the Operator and deploy your MySQL cluster

  1. Create a namespace and set the context for the namespace. The resource names must be unique within the namespace and provide a way to divide cluster resources between users spread across multiple projects.

    So, create the namespace and save it in the namespace context for subsequent commands as follows (replace the <namespace name> placeholder with some descriptive name):

    $ kubectl create namespace <namespace name>
    $ kubectl config set-context $(kubectl config current-context) --namespace=<namespace name>
    

    At success, you will see the message that namespace/ was created, and the context was modified.

  2. Use the following git clone command to download the correct branch of the percona-server-mysql-operator repository:

    $ git clone -b v0.6.0 https://github.com/percona/percona-server-mysql-operator
    

    After the repository is downloaded, change the directory to run the rest of the commands in this document:

    $ cd percona-server-mysql-operator
    
  3. Deploy the Operator using the following command:

    $ kubectl apply --server-side -f deploy/bundle.yaml
    

    The following confirmation is returned:

    customresourcedefinition.apiextensions.k8s.io/perconaserverformysqlbackups.ps.percona.com created
    customresourcedefinition.apiextensions.k8s.io/perconaserverformysqlrestores.ps.percona.com created
    customresourcedefinition.apiextensions.k8s.io/perconaserverformysqls.ps.percona.com created
    serviceaccount/percona-server-for-mysql-operator created
    role.rbac.authorization.k8s.io/percona-server-for-mysql-operator-leader-election-role created
    role.rbac.authorization.k8s.io/percona-server-for-mysql-operator-role created
    rolebinding.rbac.authorization.k8s.io/percona-server-for-mysql-operator-leader-election-rolebinding created
    rolebinding.rbac.authorization.k8s.io/percona-server-for-mysql-operator-rolebinding created
    configmap/percona-server-for-mysql-operator-config created
    deployment.apps/percona-server-for-mysql-operator created
    
  4. The operator has been started, and you can create the Percona Distribution for MySQL cluster:

    $ kubectl apply -f deploy/cr.yaml
    

    The process could take some time. The return statement confirms the creation:

    perconaserverformysql.ps.percona.com/cluster1 created
    
  5. During previous steps, the Operator has generated several secrets , including the password for the root user, which you will need to access the cluster.

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

    ...
    data:
      ...
      root: cm9vdF9wYXNzd29yZA==
    

    Here the actual password is base64-encoded, and echo 'cm9vdF9wYXNzd29yZA==' | base64 --decode will bring it back to a human-readable form (in this example it will be a root_password string).

  6. Now you can check wether you are able to connect to MySQL from the outside with the help of the kubectl port-forward command as follows:

    $ kubectl port-forward svc/cluster1-mysql-primary 3306:3306 &
    $ mysql -h 127.0.0.1 -P 3306 -uroot -proot_password
    

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-03-22