Table of Contents
The Terraform Provider for Severalnines ClusterControl offers a seamless integration between the powerful infrastructure management tool, Terraform, and the robust database management capabilities of ClusterControl.
This provider empowers users to effortlessly provision, configure, and manage database clusters through Infrastructure as Code (IaC), streamlining the deployment process and enhancing the efficiency of managing complex database environments.
With a range of customizable configurations and automation capabilities, this provider simplifies the orchestration of database infrastructure, enabling teams to focus on innovation and development rather than mundane operational tasks. Leveraging the flexibility and scalability of Terraform alongside the comprehensive management features of Severalnines ClusterControl, organizations can achieve greater agility, reliability, and scalability in their database operations.
This project is hosted in Github, terraform-provider-clustercontrol.
Requirements
Name | Version |
---|---|
Terraform | >= 0.13.x |
ClusterControl | >= 1.9.8 |
Providers
Name | Version |
---|---|
Terraform ClusterControl Provider | >= 0.1 |
Resources
Quick Start
Installing and configuring ClusterControl for API access
To get started, you may follow the following steps (if you already have ClusterControl running in your env, skip to #4):
1. Getting started with ClusterControl
2. ClusterControl installation requirements
4. Configure ClusterControl – Enable ClusterControl for API access by editing /etc/default/cmon
with a text editor and set the RPC_BIND_ADDRESSES
as shown below:
RPC_BIND_ADDRESSES="10.0.0.15,127.0.0.1"
Where 10.0.0.5
is the private IP of the ClusterControl host. Restart the ClusterControl service to apply the changes:
sudo systemctl restart cmon
5. Run a quick test to make sure you can access ClusterControl via its REST API (using curl or Postman):
curl -k 'https://10.0.0.5:9501/v2/clusters' -XPOST -d '{"operation": "getAllClusterInfo", "authenticate": {"username": "CHANGE-ME","password": "CHANGE-ME"}}'
Where username
and password
are valid login credentials for ClusterControl. The output should be a load of JSON text returned with details of the clusters managed by ClusterControl.
Deploying database clusters using Terraform for ClusterControl
Go to the examples folder for concrete examples on deploying database clusters of various types (MySQL/MariaDB replication or Galera with ProxySQL, PostgreSQL/TimescaleDB/EnterpriseDB replication, MongoDB replica set and/or sharded, Redis Sentinel, Microsoft SQL Server, and Elasticsearch)
Navigate to the docs folder for generated documentation on the terraform provider plugin for ClusterControl.
Setup terraform.tfvars
file with the following secrets.
cc_api_url="https://<cc-host-or-ip>:9501/v2"
cc_api_user="CHANGE-ME"
cc_api_user_password="CHANGE-ME"
Running terraform to deploy database clusters
After creating the appropriate terraform.tfvars
, you can start the deployment as below:
terraform init
terraform validate
terraform plan -var-file="terraform.tfvars"
terraform apply -var-file="terraform.tfvars"
Destroying a deployed database cluster
After navigating to the appropriate directory which was used to deploy a cluster:
terraform destroy -var-file="terraform.tfvars"