We are looking to provide simplified ways to deploy Percona software in cloud environments, especially for more advanced scenarios like replication and multi-node cluster (in the case of Percona XtraDB Cluster).
For this I propose trying out our new Terraform provider, with the capabilities:
To get more understanding let’s review some examples, but before that, where you can obtain modules:
The provider is available from Terraform registry:
https://registry.terraform.io/providers/Percona-Lab/percona/0.9.0
And source code at GitHub:
Keep in mind that this is an EXPERIMENTAL software yet and is not covered by Percona Support.
Examples:
As a single server is quite trivial, let’s jump to more complex scenarios: Asynchronous replication between two nodes.
Here is our main.tf file:
|
1 |
# AWS provider configuration<br>provider "percona" {<br> region = "us-east-2"<br> profile = "default"<br> cloud = "aws"<br>}<br> <br> <br>resource "percona_ps" "psrepl2" {<br> instance_type = "t3.micro" # for AWS<br> key_pair_name = "sshKey2"<br> password = "password"<br> replica_password = "replicaPassword"<br> cluster_size = 2<br> volume_size = 30<br>}<br> |
And we apply with:
|
1 |
terraform apply<br>…<br>percona_ps.psrepl2: Still creating... [4m20s elapsed]<br>percona_ps.psrepl2: Still creating... [4m30s elapsed]<br>percona_ps.psrepl2: Still creating... [4m40s elapsed]<br>percona_ps.psrepl2: Creation complete after 4m47s [id=JZnEGllTfJIOqjgMyyRl]<br> |
So five minutes later we have the following:
Similarly, for deploying a 3 node Percona XtraDB Cluster, we use:
|
1 |
# AWS provider configuration<br>provider "percona" {<br> region = "us-east-2"<br> profile = "default"<br> cloud = "aws"<br>}<br> <br> <br>resource "percona_pxc" "pxc3" {<br> instance_type = "t3.micro" # for AWS<br> key_pair_name = "sshKey2"<br> password = "password"<br> cluster_size = 3<br> volume_size = 30<br>}<br> |
Now we also can show an example for Google Cloud:
|
1 |
provider "percona" {<br> region = "us-central1"<br> zone = "us-central1-a"<br> project = "cto-lab-284219"<br> cloud = "gcp"<br>}<br> <br> <br>resource "percona_ps" "ps3" {<br> instance_type = "e2-highmem-2" <br> key_pair_name = "sshKey2"<br> password = "password"<br> cluster_size = 3<br> volume_type = "pd-ssd"<br> volume_size = 40<br>}<br> |
In this case, we will use more powerful instances with dedicated SSD volumes of 40GB each.
The script will deploy instances and install three Percona Server for MySQL servers connected in replication (one source and two replicas).
In conclusion:
We offer a Terraform provider that simplifies the deployment of Percona Server for MySQL and Percona XtraDB Cluster in cloud environments and offers various customizations for instances and replication configurations.