Skip to content

Commit 842a9aa

Browse files
Merge pull request #4 from RohitSquareops/main
Updated variable, readme and indentation
2 parents 689535f + 941f876 commit 842a9aa

File tree

7 files changed

+71
-55
lines changed

7 files changed

+71
-55
lines changed

README.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,46 @@
66

77
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
88
<br>
9+
This module is for deploying a highly available MongoDB cluster on Kubernetes using Helm charts. This module provides flexible configuration options to customize the MongoDB deployment such as setting the volume size, architecture, replica count, and more. It also includes options to enable MongoDB backups and restores, and to deploy MongoDB exporters for getting metrics in Grafana. Additionally, this module provides options to create a new namespace, and to configure recovery windows for AWS Secrets Manager. With this module, users can easily deploy a highly available MongoDB cluster on Kubernetes with the flexibility to customize their configurations according to their needs.
10+
11+
## Supported Versions:
12+
13+
| MongoDB Helm Chart Version | K8s supported version |
14+
| :-----: | :--- |
15+
| **13.1.5** | **1.23,1.24,1.25** |
16+
917

1018
## Usage Example
1119

1220
```hcl
1321
module "mongodb" {
14-
source = "../../"
22+
source = "https://github.com/sq-ia/terraform-kubernetes-mongodb.git"
1523
cluster_name = "dev-skaf"
1624
mongodb_config = {
1725
name = "skaf"
18-
values_yaml = file("./helm/values.yaml")
26+
values_yaml = ""
1927
environment = "prod"
2028
volume_size = "10Gi"
2129
architecture = "replicaset"
2230
replica_count = 2
2331
storage_class_name = "gp2"
2432
}
33+
mongodb_backup_enabled = true
2534
mongodb_backup_config = {
26-
s3_bucket_uri = "s3://bucket-name"
27-
s3_bucket_region = "us-east-2"
28-
cron_for_full_backup = "*/2 * * * *"
35+
s3_bucket_uri = ""
36+
s3_bucket_region = ""
37+
cron_for_full_backup = "* * * * *"
38+
}
39+
40+
mongodb_restore_enabled = true
41+
mongodb_restore_config = {
42+
s3_bucket_uri = ""
43+
s3_bucket_region = ""
44+
full_restore_enable = true
45+
file_name_full = ""
46+
incremental_restore_enable = false
47+
file_name_incremental = ""
2948
}
30-
mongodb_backup_enabled = true
3149
mongodb_exporter_enabled = true
3250
}
3351
@@ -87,19 +105,19 @@ No modules.
87105

88106
| Name | Description | Type | Default | Required |
89107
|------|-------------|------|---------|:--------:|
90-
| <a name="input_app_version"></a> [app\_version](#input\_app\_version) | Enter app version of application | `string` | `"5.0.8-debian-10-r9"` | no |
91-
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Enter chart version of application | `string` | `"13.1.5"` | no |
92-
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster | `string` | `""` | no |
93-
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Set it to true to create given namespace | `string` | `true` | no |
94-
| <a name="input_mongodb_backup_config"></a> [mongodb\_backup\_config](#input\_mongodb\_backup\_config) | Mongodb Backup configurations | `any` | <pre>{<br> "cron_for_full_backup": "*/5 * * * *",<br> "s3_bucket_region": "us-east-2",<br> "s3_bucket_uri": ""<br>}</pre> | no |
95-
| <a name="input_mongodb_backup_enabled"></a> [mongodb\_backup\_enabled](#input\_mongodb\_backup\_enabled) | Set true to enable mongodb backups | `bool` | `false` | no |
96-
| <a name="input_mongodb_config"></a> [mongodb\_config](#input\_mongodb\_config) | Mongodb configurations | `any` | <pre>{<br> "architecture": "",<br> "environment": "",<br> "name": "",<br> "replica_count": 2,<br> "storage_class_name": "",<br> "values_yaml": "",<br> "volume_size": ""<br>}</pre> | no |
97-
| <a name="input_mongodb_exporter_config"></a> [mongodb\_exporter\_config](#input\_mongodb\_exporter\_config) | Mongodb exporter configuration | `any` | <pre>{<br> "version": "2.9.0"<br>}</pre> | no |
98-
| <a name="input_mongodb_exporter_enabled"></a> [mongodb\_exporter\_enabled](#input\_mongodb\_exporter\_enabled) | Set true to deploy mongodb exporters to get metrics in grafana | `bool` | `false` | no |
99-
| <a name="input_mongodb_restore_config"></a> [mongodb\_restore\_config](#input\_mongodb\_restore\_config) | Mongodb restore configurations | `any` | <pre>{<br> "file_name_full": "",<br> "file_name_incremental": "",<br> "full_restore_enable": false,<br> "incremental_restore_enable": false,<br> "s3_bucket_region": "us-east-2",<br> "s3_bucket_uri": "s3://mymongo/mongodumpfull_20230424_112501.gz"<br>}</pre> | no |
100-
| <a name="input_mongodb_restore_enabled"></a> [mongodb\_restore\_enabled](#input\_mongodb\_restore\_enabled) | Set true to enable mongodb restore | `bool` | `false` | no |
101-
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Enter namespace name | `string` | `"mongodb"` | no |
102-
| <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 |
108+
| <a name="input_app_version"></a> [app\_version](#input\_app\_version) | Version of the Mongodb application that will be deployed. | `string` | `"5.0.8-debian-10-r9"` | no |
109+
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | Version of the Mongodb chart that will be used to deploy Mongodb application. | `string` | `"13.1.5"` | no |
110+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Specifies the name of the EKS cluster to deploy the Mongodb application on. | `string` | `""` | no |
111+
| <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 |
112+
| <a name="input_mongodb_backup_config"></a> [mongodb\_backup\_config](#input\_mongodb\_backup\_config) | Configuration options for Mongodb 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": "*/5 * * * *",<br> "s3_bucket_region": "us-east-2",<br> "s3_bucket_uri": ""<br>}</pre> | no |
113+
| <a name="input_mongodb_backup_enabled"></a> [mongodb\_backup\_enabled](#input\_mongodb\_backup\_enabled) | Specifies whether to enable backups for Mongodb database. | `bool` | `false` | no |
114+
| <a name="input_mongodb_config"></a> [mongodb\_config](#input\_mongodb\_config) | Specify the configuration settings for Mongodb, including the name, environment, storage options, replication settings, and custom YAML values. | `any` | <pre>{<br> "architecture": "",<br> "environment": "",<br> "name": "",<br> "replica_count": 2,<br> "storage_class_name": "",<br> "values_yaml": "",<br> "volume_size": ""<br>}</pre> | no |
115+
| <a name="input_mongodb_exporter_config"></a> [mongodb\_exporter\_config](#input\_mongodb\_exporter\_config) | Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana. | `any` | <pre>{<br> "version": "2.9.0"<br>}</pre> | no |
116+
| <a name="input_mongodb_exporter_enabled"></a> [mongodb\_exporter\_enabled](#input\_mongodb\_exporter\_enabled) | Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana. | `bool` | `false` | no |
117+
| <a name="input_mongodb_restore_config"></a> [mongodb\_restore\_config](#input\_mongodb\_restore\_config) | Configuration options for restoring dump to the Mongodb database. | `any` | <pre>{<br> "file_name_full": "",<br> "file_name_incremental": "",<br> "full_restore_enable": false,<br> "incremental_restore_enable": false,<br> "s3_bucket_region": "us-east-2",<br> "s3_bucket_uri": "s3://mymongo/mongodumpfull_20230424_112501.gz"<br>}</pre> | no |
118+
| <a name="input_mongodb_restore_enabled"></a> [mongodb\_restore\_enabled](#input\_mongodb\_restore\_enabled) | Specifies whether to enable restoring dump to the Mongodb database. | `bool` | `false` | no |
119+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the Mongodb deployment will be deployed. | `string` | `"mongodb"` | no |
120+
| <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 |
103121

104122
## Outputs
105123

example/complete/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ No requirements.
2121

2222
| Name | Source | Version |
2323
|------|--------|---------|
24-
| <a name="module_mongodb"></a> [mongodb](#module\_mongodb) | ../../ | n/a |
24+
| <a name="module_mongodb"></a> [mongodb](#module\_mongodb) | https://github.com/sq-ia/terraform-kubernetes-mongodb.git | n/a |
2525

2626
## Resources
2727

@@ -39,5 +39,4 @@ No inputs.
3939
| Name | Description |
4040
|------|-------------|
4141
| <a name="output_mongodb_configuration"></a> [mongodb\_configuration](#output\_mongodb\_configuration) | Mongodb\_Info |
42-
| <a name="output_mongodb_endpoint"></a> [mongodb\_endpoint](#output\_mongodb\_endpoint) | n/a |
4342
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

example/complete/main.tf

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
locals {
2+
name = "mongo"
23
region = "us-east-2"
3-
name = "dev"
4-
environment = "skaf"
5-
4+
environment = "prod"
5+
additional_tags = {
6+
Owner = "organization_name"
7+
Expires = "Never"
8+
Department = "Engineering"
9+
}
610
}
711

812
module "mongodb" {
9-
source = "../../"
10-
cluster_name = "dev-skaf"
13+
source = "https://github.com/sq-ia/terraform-kubernetes-mongodb.git"
14+
cluster_name = "dev-cluster"
1115
mongodb_config = {
1216
name = local.name
1317
values_yaml = file("./helm/values.yaml")
@@ -17,14 +21,12 @@ module "mongodb" {
1721
replica_count = 2
1822
storage_class_name = "gp2"
1923
}
24+
mongodb_backup_enabled = true
2025
mongodb_backup_config = {
2126
s3_bucket_uri = "s3://mymongo"
2227
s3_bucket_region = local.region
2328
cron_for_full_backup = "*/2 * * * *"
2429
}
25-
mongodb_backup_enabled = true
26-
mongodb_exporter_enabled = false
27-
2830
mongodb_restore_enabled = true
2931
mongodb_restore_config = {
3032
s3_bucket_uri = "s3://mymongo/mongodumpfull_20230424_112501.gz"
@@ -34,5 +36,5 @@ module "mongodb" {
3436
incremental_restore_enable = false
3537
file_name_incremental = ""
3638
}
37-
39+
mongodb_exporter_enabled = true
3840
}

example/complete/output.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@ output "mongodb_configuration" {
22
value = module.mongodb.mongodb
33
description = "Mongodb_Info"
44
}
5-
6-
output "mongodb_endpoint" {
7-
value = module.mongodb.mongodb_endpoint
8-
}

example/complete/provider.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
provider "aws" {
22
region = local.region
3+
default_tags {
4+
tags = local.additional_tags
5+
}
36
}
47

5-
68
data "aws_eks_cluster" "cluster" {
7-
name = "test-squareops"
9+
name = ""
810
}
911

1012
data "aws_eks_cluster_auth" "cluster" {
11-
name = "test-squareops"
13+
name = ""
1214
}
1315

14-
1516
provider "kubernetes" {
1617
host = data.aws_eks_cluster.cluster.endpoint
1718
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ resource "helm_release" "mongodb_restore" {
162162
s3_role_arn = aws_iam_role.mongo_restore_role.arn,
163163
s3_bucket_uri = var.mongodb_restore_config.s3_bucket_uri,
164164
s3_bucket_region = var.mongodb_restore_config.s3_bucket_region,
165-
mongodb_root_user_password = random_password.mongodb_root_password.result,
166-
full_restore_enable = var.mongodb_restore_config.full_restore_enable,
167165
file_name_full = var.mongodb_restore_config.file_name_full,
166+
full_restore_enable = var.mongodb_restore_config.full_restore_enable,
167+
file_name_incremental = var.mongodb_restore_config.file_name_incremental,
168168
incremental_restore_enable = var.mongodb_restore_config.incremental_restore_enable,
169-
file_name_incremental = var.mongodb_restore_config.file_name_incremental
169+
mongodb_root_user_password = random_password.mongodb_root_password.result
170170
})
171171
]
172172
}

variables.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ variable "mongodb_config" {
99
values_yaml = ""
1010
storage_class_name = ""
1111
}
12-
description = "Mongodb configurations"
12+
description = "Specify the configuration settings for Mongodb, including the name, environment, storage options, replication settings, and custom YAML values."
1313
}
1414

1515
variable "chart_version" {
1616
type = string
1717
default = "13.1.5"
18-
description = "Enter chart version of application"
18+
description = "Version of the Mongodb chart that will be used to deploy Mongodb application."
1919
}
2020

2121
variable "app_version" {
2222
type = string
2323
default = "5.0.8-debian-10-r9"
24-
description = "Enter app version of application"
24+
description = "Version of the Mongodb application that will be deployed."
2525
}
2626

2727
variable "namespace" {
2828
type = string
2929
default = "mongodb"
30-
description = "Enter namespace name"
30+
description = "Name of the Kubernetes namespace where the Mongodb deployment will be deployed."
3131
}
3232

3333
variable "mongodb_backup_enabled" {
3434
type = bool
3535
default = false
36-
description = "Set true to enable mongodb backups"
36+
description = "Specifies whether to enable backups for Mongodb database."
3737
}
3838

3939
variable "mongodb_backup_config" {
@@ -43,45 +43,45 @@ variable "mongodb_backup_config" {
4343
s3_bucket_region = "us-east-2"
4444
cron_for_full_backup = "*/5 * * * *"
4545
}
46-
description = "Mongodb Backup configurations"
46+
description = "Configuration options for Mongodb database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups."
4747
}
4848

4949
variable "mongodb_exporter_enabled" {
5050
type = bool
5151
default = false
52-
description = "Set true to deploy mongodb exporters to get metrics in grafana"
52+
description = "Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana."
5353
}
5454

5555
variable "mongodb_exporter_config" {
5656
type = any
5757
default = {
5858
version = "2.9.0"
5959
}
60-
description = "Mongodb exporter configuration"
60+
description = "Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana."
6161
}
6262

6363
variable "recovery_window_aws_secret" {
64-
default = 0
6564
type = number
66-
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."
65+
default = 0
66+
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."
6767
}
6868

6969
variable "cluster_name" {
7070
type = string
71-
description = "Name of the EKS cluster"
7271
default = ""
72+
description = "Specifies the name of the EKS cluster to deploy the Mongodb application on."
7373
}
7474

7575
variable "create_namespace" {
7676
type = string
77-
description = "Set it to true to create given namespace"
7877
default = true
78+
description = "Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace."
7979
}
8080

8181
variable "mongodb_restore_enabled" {
8282
type = bool
8383
default = false
84-
description = "Set true to enable mongodb restore"
84+
description = "Specifies whether to enable restoring dump to the Mongodb database."
8585
}
8686

8787
variable "mongodb_restore_config" {
@@ -94,5 +94,5 @@ variable "mongodb_restore_config" {
9494
incremental_restore_enable = false
9595
file_name_incremental = ""
9696
}
97-
description = "Mongodb restore configurations"
97+
description = "Configuration options for restoring dump to the Mongodb database."
9898
}

0 commit comments

Comments
 (0)