Deploying the Percona Kubernetes Operator for XtraDB Cluster in Amazon (AWS)

Percona Kubernetes Operator for Percona XtraDB Cluster in AWSBeing that Amazon is one of the most-used cloud vendors, it is only natural that one may ask “How can Kubernetes be used in AWS?“. And the answer is – not that different than with other cloud vendors. What one needs is two things (and this applies universally): a Kubernetes cluster + the Percona XtraDB Cluster (PXC). Let’s start by creating the K8S cluster.

Amazon EKS

Like every other major cloud vendor, Amazon also has its own service available to make easy the task of creating and maintaining a K8S cluster called Amazon Elastic Kubernetes Service (EKS). There are two ways to create the cluster: one is using a tool called eksctl (which is the one we are going to use) and the other one is using the AWS management console which is a more manual approach. Now, before deploying the cluster with eksctl, there are a few requirements that need to be met:

  • Have kubectl installed
  • Have the latest AWS CLI installed
  • Have AWS IAM authenticator
  • And, of course, have eksctl installed

Installing kubectl

There is more than one way to get kubectl. We are going to install the binary hosted by Amazon (compatible with the upstream version). The following steps are for Linux:

Once that is done, you can verify that the installation was done properly by asking for the version: kubectl version –short –client.

All good!

Installing the AWS CLI

To get the new (experimental) AWS CLI version 2, run:

Verifying:

You can export the /usr/local/bin path to the environment variable PATH so you can use the “aws2” command directly.

Installing AWS IAM Authenticator

Similar to the previous installations, just run the following commands as described in the AWS IAM authenticator documentation:

And validate:

Don’t forget to configure your AWS CLI credentials, for example (not real info):

Installing eksctl

Similar instructions. Follow these steps:

And verify:

Now we are ready to deploy the Kubernetes cluster.

Creating the Kubernetes Cluster

And now the moment of truth. To create the cluster, one just needs to execute one command (with several parameters), but that is pretty much all. For this case, the command looks like this:

The parameters used are just a small subset of everything that is available, and one that can seen by running “eksctl create cluster –help”, but for this case what we asked of EKS is to create a cluster named Percona using K8S version 1.14, in the aws region us-east-2 (Ohio), giving a name of percona-standard-workers to the nodegroup, using t3.medium EC2 instances for the nodes, with a total of three nodes (min 1 max 4), and enabling SSH access for the nodes using the SSH public key provided.

Note that all these parameters can be passed using a config file with YAML format, as explained in the documentation. Now, after the command is executed, the cluster is ready to be deployed. This process is not fast and could take around 15 minutes to finish. Be patient.

The output will look like this:

You’ve got yourself a K8S cluster in AWS!

Now we can install the Percona XtraDB Cluster operator.

Deploying the Percona Kubernetes Operator for Percona XtraDB Cluster

One can follow the instructions described in the document Install Percona XtraDB Cluster on Kubernetes so let’s do that.

Clone the repo and get into the dir:

Deploy the Custom Resource Definition (CRD), add the pxc namespace, deploy the Role-Based Access Control (RBAC), the Secrets, the Operator, and finally the actual cluster:

Do we have PODs?

Yeah, we do! Now you have yourself a PXC cluster running on K8S:

Note that the Operator comes with ProxySQL. Here’s the design overview. Now, to delete the cluster (and avoid cost surprises) you should run the following command: eksctl delete cluster –region us-east-2 –name percona1.

Interested in learning more?

Be sure to get in touch with Percona’s Training Department to schedule a hands-on tutorial session with our K8S Operator. Our instructors will guide you and your team through all the setup processes, learn how to take backups, handle recovery, scale the cluster, and manage high-availability with ProxySQL.

Share this post

Leave a Reply