Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@

### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
<br>
This module allows you to easily deploy a MySQL database on Kubernetes using Helm. It provides flexible configuration options for the MySQL database, including storage class, database volume sizes, and architecture. In addition, it supports enabling backups and restoring from backups, as well as deploying MySQL database exporters to gather metrics for Grafana. This module is designed to be highly configurable and customizable, and can be easily integrated into your existing Terraform infrastructure code.

## Supported Versions:

| MysqlDB Helm Chart Version | K8s supported version |
| :-----: | :--- |
| **9.2.0** | **1.23,1.24,1.25** |


## Usage Example

```hcl
module "mysql" {
source = "../.."
cluster_name = "dev-skaf"
source = "https://github.com/sq-ia/terraform-kubernetes-mysql.git"
cluster_name = "dev-cluster"
mysqldb_config = {
name = "skaf"
values_yaml = ""
environment = "prod"
architecture = "replication"
storage_class_name = "infra-service-sc"
storage_class_name = "gp2"
custom_user_username = "admin"
primary_db_volume_size = "10Gi"
secondary_db_volume_size = "10Gi"
secondary_db_replica_count = 2
}
mysqldb_backup_enabled = true
mysqldb_backup_config = {
s3_bucket_uri = "s3://bucket-name"
s3_bucket_region = "bucket-region"
cron_for_full_backup = "*/2 * * * *"
s3_bucket_uri = ""
s3_bucket_region = ""
cron_for_full_backup = "* * * * *"
}
mysqldb_restore_enabled = true
mysqldb_restore_config = {
s3_bucket_uri = ""
s3_bucket_region = ""
}
mysqldb_exporter_enabled = true
}
Expand Down Expand Up @@ -89,24 +102,24 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_app_version"></a> [app\_version](#input\_app\_version) | App version | `string` | `"8.0.29-debian-11-r9"` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Chart version | `string` | `"9.2.0"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster | `string` | `""` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Set it to true to create given namespace | `string` | `true` | no |
| <a name="input_mysqldb_backup_config"></a> [mysqldb\_backup\_config](#input\_mysqldb\_backup\_config) | Mysql Backup configurations | `any` | <pre>{<br> "cron_for_full_backup": "",<br> "s3_bucket_region": "",<br> "s3_bucket_uri": ""<br>}</pre> | no |
| <a name="input_mysqldb_backup_enabled"></a> [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Set true to enable mysql backups | `bool` | `false` | no |
| <a name="input_mysqldb_config"></a> [mysqldb\_config](#input\_mysqldb\_config) | Mysql configurations | `any` | <pre>{<br> "architecture": "",<br> "custom_user_username": "",<br> "environment": "",<br> "name": "",<br> "primary_db_volume_size": "",<br> "secondary_db_replica_count": 1,<br> "secondary_db_volume_size": "",<br> "storage_class_name": "",<br> "values_yaml": ""<br>}</pre> | no |
| <a name="input_mysqldb_exporter_enabled"></a> [mysqldb\_exporter\_enabled](#input\_mysqldb\_exporter\_enabled) | Set true to deploy mysqldb exporters to get metrics in grafana | `bool` | `false` | no |
| <a name="input_mysqldb_restore_config"></a> [mysqldb\_restore\_config](#input\_mysqldb\_restore\_config) | Mysql Restore configurations | `any` | <pre>{<br> "s3_bucket_region": "",<br> "s3_bucket_uri": ""<br>}</pre> | no |
| <a name="input_mysqldb_restore_enabled"></a> [mysqldb\_restore\_enabled](#input\_mysqldb\_restore\_enabled) | Set true to enable mysql restore | `bool` | `false` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace name | `string` | `"mysqldb"` | no |
| <a name="input_recovery_window_aws_secret"></a> [recovery\_window\_aws\_secret](#input\_recovery\_window\_aws\_secret) | Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be 0 to force deletion without recovery or range from 7 to 30 days. | `number` | `0` | no |
| <a name="input_app_version"></a> [app\_version](#input\_app\_version) | Version of the MySQL application that will be deployed. | `string` | `"8.0.29-debian-11-r9"` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Version of the Mysql chart that will be used to deploy MySQL application. | `string` | `"9.2.0"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Specifies the name of the EKS cluster to deploy the MySQL application on. | `string` | `""` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace. | `string` | `true` | no |
| <a name="input_mysqldb_backup_config"></a> [mysqldb\_backup\_config](#input\_mysqldb\_backup\_config) | configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups. | `any` | <pre>{<br> "cron_for_full_backup": "",<br> "s3_bucket_region": "",<br> "s3_bucket_uri": ""<br>}</pre> | no |
| <a name="input_mysqldb_backup_enabled"></a> [mysqldb\_backup\_enabled](#input\_mysqldb\_backup\_enabled) | Specifies whether to enable backups for MySQL database. | `bool` | `false` | no |
| <a name="input_mysqldb_config"></a> [mysqldb\_config](#input\_mysqldb\_config) | Specify the configuration settings for MySQL, including the name, environment, storage options, replication settings, and custom YAML values. | `any` | <pre>{<br> "architecture": "",<br> "custom_user_username": "",<br> "environment": "",<br> "name": "",<br> "primary_db_volume_size": "",<br> "secondary_db_replica_count": 1,<br> "secondary_db_volume_size": "",<br> "storage_class_name": "",<br> "values_yaml": ""<br>}</pre> | no |
| <a name="input_mysqldb_exporter_enabled"></a> [mysqldb\_exporter\_enabled](#input\_mysqldb\_exporter\_enabled) | Specify whether or not to deploy Mysql exporter to collect Mysql metrics for monitoring in Grafana. | `bool` | `false` | no |
| <a name="input_mysqldb_restore_config"></a> [mysqldb\_restore\_config](#input\_mysqldb\_restore\_config) | Configuration options for restoring dump to the MySQL database. | `any` | <pre>{<br> "s3_bucket_region": "",<br> "s3_bucket_uri": ""<br>}</pre> | no |
| <a name="input_mysqldb_restore_enabled"></a> [mysqldb\_restore\_enabled](#input\_mysqldb\_restore\_enabled) | Specifies whether to enable restoring dump to the MySQL database. | `bool` | `false` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"mysqldb"` | no |
| <a name="input_recovery_window_aws_secret"></a> [recovery\_window\_aws\_secret](#input\_recovery\_window\_aws\_secret) | Number of days that AWS Secrets Manager will wait before deleting a secret. This value can be set to 0 to force immediate deletion, or to a value between 7 and 30 days to allow for recovery. | `number` | `0` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_mysqldb"></a> [mysqldb](#output\_mysqldb) | MysqlDB\_Info |
| <a name="output_mysqldb"></a> [mysqldb](#output\_mysqldb) | Mysql\_Info |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## Contribution & Issue Reporting
Expand Down
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ No requirements.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_mysql"></a> [mysql](#module\_mysql) | ../../ | n/a |
| <a name="module_mysql"></a> [mysql](#module\_mysql) | https://github.com/sq-ia/terraform-kubernetes-mysql.git | n/a |

## Resources

Expand All @@ -38,5 +38,5 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_mysql_configuration"></a> [mysql\_configuration](#output\_mysql\_configuration) | mysql\_Info |
| <a name="output_mysql_configuration"></a> [mysql\_configuration](#output\_mysql\_configuration) | Mysql\_Info |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
18 changes: 11 additions & 7 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
locals {
name = "test"
region = "ap-south-1"
environment = "squareops"
name = "mysql"
region = "us-east-2"
environment = "prod"
additional_tags = {
Owner = "organization_name"
Expires = "Never"
Department = "Engineering"
}
}

module "mysql" {
source = "../../"
cluster_name = "test-squareops"
source = "https://github.com/sq-ia/terraform-kubernetes-mysql.git"
cluster_name = ""
mysqldb_config = {
name = local.name
values_yaml = file("./helm/values.yaml")
Expand All @@ -28,7 +33,6 @@ module "mysql" {
mysqldb_restore_config = {
s3_bucket_uri = "s3://mysqldumprestore/10-dump.sql"
s3_bucket_region = "us-east-2"

}
mysqldb_exporter_enabled = false
mysqldb_exporter_enabled = true
}
2 changes: 1 addition & 1 deletion examples/complete/output.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "mysql_configuration" {
value = module.mysql.mysqldb
description = "mysql_Info"
description = "Mysql_Info"
}
7 changes: 5 additions & 2 deletions examples/complete/provider.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
provider "aws" {
region = local.region
default_tags {
tags = local.additional_tags
}
}


data "aws_eks_cluster" "cluster" {
name = "dev-skaf"
name = ""
}

data "aws_eks_cluster_auth" "cluster" {
name = "dev-skaf"
name = ""
}


Expand Down
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "mysqldb" {
description = "MysqlDB_Info"
description = "Mysql_Info"
value = {
mysqlport = "3306",
mysql_primary_endpoint = "mysqldb-primary.${var.namespace}.svc.cluster.local",
Expand Down
24 changes: 12 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ variable "mysqldb_config" {
secondary_db_volume_size = ""
secondary_db_replica_count = 1
}
description = "Mysql configurations"
description = "Specify the configuration settings for MySQL, including the name, environment, storage options, replication settings, and custom YAML values."
}

variable "app_version" {
type = string
default = "8.0.29-debian-11-r9"
description = "App version"
description = "Version of the MySQL application that will be deployed."
}

variable "chart_version" {
type = string
default = "9.2.0"
description = "Chart version"
description = "Version of the Mysql chart that will be used to deploy MySQL application."
}

variable "namespace" {
type = string
default = "mysqldb"
description = "Namespace name"
description = "Name of the Kubernetes namespace where the MYSQL deployment will be deployed."
}
variable "mysqldb_backup_enabled" {
type = bool
default = false
description = "Set true to enable mysql backups"
description = "Specifies whether to enable backups for MySQL database."
}

variable "mysqldb_backup_config" {
Expand All @@ -44,37 +44,37 @@ variable "mysqldb_backup_config" {
s3_bucket_region = ""
cron_for_full_backup = ""
}
description = "Mysql Backup configurations"
description = "configuration options for MySQL database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups."
}

variable "mysqldb_exporter_enabled" {
type = bool
default = false
description = "Set true to deploy mysqldb exporters to get metrics in grafana"
description = "Specify whether or not to deploy Mysql exporter to collect Mysql metrics for monitoring in Grafana."
}

variable "recovery_window_aws_secret" {
type = number
default = 0
description = "Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be 0 to force deletion without recovery or range from 7 to 30 days."
description = "Number of days that AWS Secrets Manager will wait before deleting a secret. This value can be set to 0 to force immediate deletion, or to a value between 7 and 30 days to allow for recovery."
}

variable "cluster_name" {
type = string
default = ""
description = "Name of the EKS cluster"
description = "Specifies the name of the EKS cluster to deploy the MySQL application on."
}

variable "create_namespace" {
type = string
description = "Set it to true to create given namespace"
description = "Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace."
default = true
}

variable "mysqldb_restore_enabled" {
type = bool
default = false
description = "Set true to enable mysql restore"
description = "Specifies whether to enable restoring dump to the MySQL database."
}

variable "mysqldb_restore_config" {
Expand All @@ -83,5 +83,5 @@ variable "mysqldb_restore_config" {
s3_bucket_uri = ""
s3_bucket_region = ""
}
description = "Mysql Restore configurations"
description = "Configuration options for restoring dump to the MySQL database."
}