Deploy Percona Monitoring and Management on Amazon EKS With eksctl and Helm
Tags: kubernetes, aws, monitoring, cloud
Published: 2023-03-22 13:21:57

One of the installation methods we support for our database software is through [Helm](https://helm.sh/). We have a collection of Helm charts, in [this repository](https://github.com/percona/percona-helm-charts), for the following Percona software:

- Percona Operator for MySQL
- Percona XtraDB Cluster
- Percona Operator for MongoDB
- Percona Server for MongoDB
- Percona Operator for PostgreSQL
- Percona Distribution for PostgreSQL
- Percona Monitoring and Management (PMM)

Through this blog post, you will learn how to install Percona Monitoring and Management in a Kubernetes cluster on Amazon EKS using Helm and eksctl.

## Requirements

For the installation of PMM with Helm, you will need:

- Kubernetes 1.22+
- Helm 3.2.0+
- PV (Persistent Volume) provisioner support in the underlying infrastructure

If you want to install PMM in a Kubernetes cluster on Amazon EKS, you can use eksctl to create the required cluster. I published [this blog post](https://percona.community/blog/2022/09/13/creating-a-kubernetes-cluster-on-amazon-eks-with-eksctl/) in the Percona Community blog where I explain how to use this tool.

For an easy way to deploy the Kubernetes cluster, check [Percona My Database as a Service (MyDBaas)](https://mydbaas.labs.percona.com/), a Percona Labs project. I also recommend checking [this article](https://www.percona.com/blog/percona-labs-presents-infrastructure-generator-for-percona-database-as-a-service-dbaas/) in our blog where the process of creating the cluster is described

MyDBaaS will help you with cluster creation. It will generate the configuration file needed for eksctl, or it can deploy the cluster to AWS.

To use eksctl you must:

- Install [kubectl](https://kubernetes.io/docs/tasks/tools/)
- Create a user with [minimum IAM policies](https://eksctl.io/usage/minimum-iam-policies/)
- Create an access key ID and secret access key for the user previously created
- Install [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) and configure authentication (aws configure , from the command line)
- Install [eksctl](https://github.com/weaveworks/eksctl#installation)

## Create a Kubernetes cluster

To create the cluster, you will need to generate the configuration file for eksctl. Go to [https://mydbaas.labs.percona.com/](https://mydbaas.labs.percona.com/) and fill out the details of your cluster.

![Figure 1: MyDBaaS - Kubernetes Cluster Configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ud3xb2pprhe35mug5a7.png "Figure 1: MyDBaaS - Kubernetes Cluster Configuration")

- Give your cluster a name. MyDbaas is the default value
- Select the number of nodes. The value selected by default is 3 but you can create a cluster of up to 5 nodes
- Write the instance type
- Select the region. The default is `us-west-2`

If you don’t know what instance type to use, go to the Instance Type Selector and select:

- Number of CPUs
- Memory size
- Region


![Figure 2: MyDBaaS - Instance Type Selector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ipodjbzhqmpys9myv2jw.png "Figure 2: MyDBaaS - Instance Type Selector")

As stated on the website, this tool will only return the configuration file needed for eksctl. You can also provide your AWS credentials for the tool to deploy the EKS cluster.

After filling out the details, click on `Submit` and you will get the configuration file that will look like this:

```yaml
addons:
- name: aws-ebs-csi-driver
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: MyDbaas
  region: us-east-1
nodeGroups:
- desiredCapacity: 2
  iam:
    withAddonPolicies:
      ebs: true
      efs: true
      fsx: true
  instanceType: m5.large
  maxSize: 5
  minSize: 1
  name: ng-1
  preBootstrapCommands:
  - echo 'OPTIONS="--default-ulimit nofile=1048576:1048576"' >> /etc/sysconfig/docker
  - systemctl restart docker
  volumeSize: 100
  volumeType: gp2
```

Then, create the cluster by running the following command:

```
eksctl create cluster -f cluster.yaml
```

While running, eksctl will create the cluster and all the necessary resources. It will take a few minutes to complete.

![Figure 3: eksctl Running](https://percona.community/blog/2022/9/eksctl_running_huc9b9868d7114ba5624169616df63d1a0_337950_1400x0_resize_lanczos_2.png "Figure 3: eksctl Running")

Cluster credentials can be found in `~/.kube/config` . Try `kubectl get nodes`  to verify that this file is valid, as suggested by eksctl.

## Install PMM with Helm

Once the cluster has been created and configured, you can install PMM using Helm.

1. Add the repository
```
helm repo add percona https://percona.github.io/percona-helm-charts/
```

2. Install PMM
```
helm install pmm --set service.type="LoadBalancer" percona/pmm
```

Once the PMM server runs, you must get its IP address. Run this command to get this value.

```
kubectl get services monitoring-service
```

You will get an output similar to the following.

```
NAME                 TYPE           CLUSTER-IP      EXTERNAL-IP                                                              PORT(S)                      AGE
monitoring-service   LoadBalancer   10.100.17.121   a57d50410ca2f4c9d9b029da8f44f73f-254463297.us-east-1.elb.amazonaws.com   443:30252/TCP,80:31201/TCP   100s
```

`a57d50410ca2f4c9d9b029da8f44f73f-254463297.us-east-1.elb.amazonaws.com` is the external IP and the one you need to access PMM from the browser.

Before accessing the dashboard of PMM, get the password.

```
export ADMIN_PASS=$(kubectl get secret pmm-secret --namespace default -o jsonpath='{.data.PMM_ADMIN_PASSWORD}' | base64 --decode)
echo $ADMIN_PASS
```

The value of `$ADMIN_PASS`  is the password you need to log into the dashboard. The default user is `admin`.

Go to the browser and paste the external IP in the address bar.


![Figure 4: PMM running on Kubernetes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2djhbphz0hqxvn4n8zm.png "Figure 4: PMM running on Kubernetes")

Now you have PMM running in the cloud on Amazon EKS.

I would recommend that you check [this article](https://www.percona.com/blog/percona-monitoring-and-management-in-kubernetes-is-now-in-tech-preview/) in our blog for more information about PMM in Kubernetes using Helm.

## Conclusion

Through this blog post, you learned how to create a Kubernetes cluster with eksctl and deploy PMM using Helm, with the help of [Percona MyDBaaS](https://mydbaas.labs.percona.com/). The process would be the same for any of the Percona software in the collection of Helm charts.

---

This post was brought to you by [Percona](https://percona.com)
Want to try [Percona Monitoring and Management](https://www.percona.com/software/database-tools/percona-monitoring-and-management)? Check our [demo](http://pmmdemo.percona.com/)