Skip to content

Commit 01bd842

Browse files
Merge pull request #17 from ns-squareops/main
added affinity and resource request and limit for backup and restore job and for mongodb exporter
2 parents fe0943d + 88f7516 commit 01bd842

File tree

14 files changed

+200
-14
lines changed

14 files changed

+200
-14
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module "aws" {
4242
source = "squareops/mongodb/kubernetes//modules/resources/aws"
4343
environment = local.environment
4444
name = local.name
45+
namespace = local.namespace
4546
store_password_to_secret_manager = local.store_password_to_secret_manager
4647
cluster_name = ""
4748
mongodb_custom_credentials_enabled = local.mongodb_custom_credentials_enabled
@@ -86,6 +87,7 @@ module "mongodb" {
8687
file_name = "mongodumpfull_20230523_092110.gz"
8788
}
8889
mongodb_exporter_enabled = true
90+
mongodb_exporter_values = file("./helm/exporter.yaml")
8991
}
9092
9193
@@ -121,11 +123,7 @@ No requirements.
121123

122124
## Modules
123125

124-
| Name | Source | Version |
125-
|------|--------|---------|
126-
| <a name="module_aws"></a> [aws](#module\_aws) | squareops/mongodb/kubernetes//provider/aws | n/a |
127-
| <a name="module_gcp"></a> [gcp](#module\_gcp) | squareops/mongodb/kubernetes//provider/gcp | n/a |
128-
| <a name="module_azure"></a> [azure](#module\_azure) | squareops/mongodb/kubernetes//provider/azure | n/a |
126+
No modules.
129127

130128
## Resources
131129

@@ -144,33 +142,37 @@ No requirements.
144142
| Name | Description | Type | Default | Required |
145143
|------|-------------|------|---------|:--------:|
146144
| <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 |
145+
| <a name="input_az_account_backup"></a> [az\_account\_backup](#input\_az\_account\_backup) | Azure user managed account backup identity | `string` | `""` | no |
146+
| <a name="input_az_account_restore"></a> [az\_account\_restore](#input\_az\_account\_restore) | Azure user managed account restore identity | `string` | `""` | no |
147+
| <a name="input_azure_container_name"></a> [azure\_container\_name](#input\_azure\_container\_name) | Azure container name | `string` | `""` | no |
148+
| <a name="input_azure_storage_account_key"></a> [azure\_storage\_account\_key](#input\_azure\_storage\_account\_key) | Azure storage account key | `string` | `""` | no |
149+
| <a name="input_azure_storage_account_name"></a> [azure\_storage\_account\_name](#input\_azure\_storage\_account\_name) | Azure storage account name | `string` | `""` | no |
147150
| <a name="input_bucket_provider_type"></a> [bucket\_provider\_type](#input\_bucket\_provider\_type) | Choose what type of provider you want (s3, gcs) | `string` | `"gcs"` | no |
148151
| <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 |
149152
| <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 |
150-
| <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 |
153+
| <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` | `false` | no |
151154
| <a name="input_iam_role_arn_backup"></a> [iam\_role\_arn\_backup](#input\_iam\_role\_arn\_backup) | IAM role ARN for backup (AWS) | `string` | `""` | no |
152155
| <a name="input_iam_role_arn_restore"></a> [iam\_role\_arn\_restore](#input\_iam\_role\_arn\_restore) | IAM role ARN for restore (AWS) | `string` | `""` | no |
153-
| <a name="input_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#input\_metric\_exporter\_pasword) | Metric exporter password for MongoDB | `string` | `""` | no |
156+
| <a name="input_metric_exporter_password"></a> [metric\_exporter\_password](#input\_metric\_exporter\_password) | Metric exporter password for MongoDB | `string` | `""` | no |
154157
| <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> "bucket_uri": "",<br> "cron_for_full_backup": "*/5 * * * *",<br> "s3_bucket_region": "us-east-2"<br>}</pre> | no |
155158
| <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 |
156-
| <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> "store_password_to_secret_manager": true,<br> "values_yaml": "",<br> "volume_size": ""<br>}</pre> | no |
159+
| <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> "custom_databases": "",<br> "custom_databases_passwords": "",<br> "custom_databases_usernames": "",<br> "environment": "",<br> "name": "",<br> "replica_count": 2,<br> "storage_class_name": "",<br> "store_password_to_secret_manager": true,<br> "values_yaml": "",<br> "volume_size": ""<br>}</pre> | no |
157160
| <a name="input_mongodb_custom_credentials_config"></a> [mongodb\_custom\_credentials\_config](#input\_mongodb\_custom\_credentials\_config) | Specify the configuration settings for Mongodb to pass custom credentials during creation. | `any` | <pre>{<br> "metric_exporter_password": "",<br> "metric_exporter_user": "",<br> "root_password": "",<br> "root_user": ""<br>}</pre> | no |
158161
| <a name="input_mongodb_custom_credentials_enabled"></a> [mongodb\_custom\_credentials\_enabled](#input\_mongodb\_custom\_credentials\_enabled) | Specifies whether to enable custom credentials for MongoDB database. | `bool` | `false` | no |
159162
| <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 |
160163
| <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 |
164+
| <a name="input_mongodb_exporter_values"></a> [mongodb\_exporter\_values](#input\_mongodb\_exporter\_values) | Mongo DB prometheus exporter values file | `any` | `""` | no |
161165
| <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> "bucket_uri": "s3://mymongo/mongodumpfull_20230424_112501.gz",<br> "file_name": "",<br> "s3_bucket_region": "us-east-2"<br>}</pre> | no |
162166
| <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 |
163167
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the Mongodb deployment will be deployed. | `string` | `"mongodb"` | no |
164168
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Google Cloud project ID | `string` | `""` | no |
165169
| <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 |
166170
| <a name="input_resource_group_location"></a> [resource\_group\_location](#input\_resource\_group\_location) | Azure region | `string` | `"East US"` | no |
167171
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Azure Resource Group name | `string` | `""` | no |
168-
| <a name="input_storage_account_name"></a> [storage\_account\_name](#input\_storage\_account\_name) | Azure storage account name | `string` | `""` | no |
169172
| <a name="input_root_password"></a> [root\_password](#input\_root\_password) | Root password for MongoDB | `string` | `""` | no |
170173
| <a name="input_service_account_backup"></a> [service\_account\_backup](#input\_service\_account\_backup) | Service account for backup (GCP) | `string` | `""` | no |
171174
| <a name="input_service_account_restore"></a> [service\_account\_restore](#input\_service\_account\_restore) | Service account for restore (GCP) | `string` | `""` | no |
172175

173-
174176
## Outputs
175177

176178
| Name | Description |

examples/complete/aws/README.md

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

2222
| Name | Source | Version |
2323
|------|--------|---------|
24-
| <a name="module_aws"></a> [aws](#module\_aws) | squareops/mongodb/kubernetes//provider/aws | n/a |
24+
| <a name="module_aws"></a> [aws](#module\_aws) | squareops/mongodb/kubernetes//modules/resources/aws | n/a |
2525
| <a name="module_mongodb"></a> [mongodb](#module\_mongodb) | squareops/mongodb/kubernetes | n/a |
2626

2727
## Resources
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
affinity:
2+
nodeAffinity:
3+
requiredDuringSchedulingIgnoredDuringExecution:
4+
nodeSelectorTerms:
5+
- matchExpressions:
6+
- key: "Infra-Services"
7+
operator: In
8+
values:
9+
- "true"
10+
resources:
11+
limits:
12+
cpu: 100m
13+
memory: 200Mi
14+
requests:
15+
cpu: 50m
16+
memory: 100Mi

examples/complete/aws/helm/values.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ affinity:
77
operator: In
88
values:
99
- "true"
10+
backupjob:
11+
resources:
12+
requests:
13+
memory: 100Mi
14+
cpu: 50m
15+
limits:
16+
memory: 200Mi
17+
cpu: 100m
18+
19+
restorejob:
20+
resources:
21+
requests:
22+
memory: 100Mi
23+
cpu: 50m
24+
limits:
25+
memory: 200Mi
26+
cpu: 100m

examples/complete/aws/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module "aws" {
2222
source = "squareops/mongodb/kubernetes//modules/resources/aws"
2323
environment = local.environment
2424
name = local.name
25+
namespace = local.namespace
2526
store_password_to_secret_manager = local.store_password_to_secret_manager
2627
cluster_name = ""
2728
mongodb_custom_credentials_enabled = local.mongodb_custom_credentials_enabled
@@ -66,4 +67,6 @@ module "mongodb" {
6667
file_name = "mongodumpfull_20230523_092110.gz"
6768
}
6869
mongodb_exporter_enabled = true
70+
mongodb_exporter_values = file("./helm/exporter.yaml")
71+
6972
}

examples/complete/azure/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,38 @@ No inputs.
4040
|------|-------------|
4141
| <a name="output_mongodb_credential"></a> [mongodb\_credential](#output\_mongodb\_credential) | MongoDB credentials used for accessing the MongoDB database. |
4242
| <a name="output_mongodb_endpoints"></a> [mongodb\_endpoints](#output\_mongodb\_endpoints) | MongoDB endpoints in the Kubernetes cluster. |
43+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
44+
## Requirements
45+
46+
No requirements.
47+
48+
## Providers
49+
50+
| Name | Version |
51+
|------|---------|
52+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | n/a |
53+
54+
## Modules
55+
56+
| Name | Source | Version |
57+
|------|--------|---------|
58+
| <a name="module_azure"></a> [azure](#module\_azure) | squareops/mongodb/kubernetes//modules/resources/azure | n/a |
59+
| <a name="module_mongodb"></a> [mongodb](#module\_mongodb) | squareops/mongodb/kubernetes | n/a |
60+
61+
## Resources
62+
63+
| Name | Type |
64+
|------|------|
65+
| [azurerm_kubernetes_cluster.primary](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) | data source |
66+
67+
## Inputs
68+
69+
No inputs.
70+
71+
## Outputs
72+
73+
| Name | Description |
74+
|------|-------------|
75+
| <a name="output_mongodb_credential"></a> [mongodb\_credential](#output\_mongodb\_credential) | MongoDB credentials used for accessing the MongoDB database. |
76+
| <a name="output_mongodb_endpoints"></a> [mongodb\_endpoints](#output\_mongodb\_endpoints) | MongoDB endpoints in the Kubernetes cluster. |
77+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/complete/gcp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ No requirements.
2222

2323
| Name | Source | Version |
2424
|------|--------|---------|
25-
| <a name="module_gcp"></a> [gcp](#module\_gcp) | squareops/mongodb/kubernetes//provider/gcp | n/a |
25+
| <a name="module_gcp"></a> [gcp](#module\_gcp) | squareops/mongodb/kubernetes//modules/resources/gcp | n/a |
2626
| <a name="module_mongodb"></a> [mongodb](#module\_mongodb) | squareops/mongodb/kubernetes | n/a |
2727

2828
## Resources

helm/values/backup/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ annotations:
1515
${annotations}
1616

1717
bucket_provider_type: ${bucket_provider_type}
18+
19+
affinity:
20+
nodeAffinity:
21+
requiredDuringSchedulingIgnoredDuringExecution:
22+
nodeSelectorTerms:
23+
- matchExpressions:
24+
- key: "Infra-Services"
25+
operator: In
26+
values:
27+
- "true"
28+
29+
backupjob:
30+
resources:
31+
requests:
32+
memory: 100Mi
33+
cpu: 50m
34+
limits:
35+
memory: 200Mi
36+
cpu: 100m

helm/values/restore/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ annotations:
1515
${annotations}
1616

1717
bucket_provider_type: ${bucket_provider_type}
18+
19+
affinity:
20+
nodeAffinity:
21+
requiredDuringSchedulingIgnoredDuringExecution:
22+
nodeSelectorTerms:
23+
- matchExpressions:
24+
- key: "Infra-Services"
25+
operator: In
26+
values:
27+
- "true"
28+
29+
restorejob:
30+
resources:
31+
requests:
32+
memory: 100Mi
33+
cpu: 50m
34+
limits:
35+
memory: 200Mi
36+
cpu: 100m

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ resource "helm_release" "mongodb_exporter" {
107107
templatefile("${path.module}/helm/values/exporter/values.yaml", {
108108
mongodb_exporter_password = var.mongodb_custom_credentials_enabled ? var.mongodb_custom_credentials_config.metric_exporter_password : "${var.metric_exporter_password}"
109109
service_monitor_namespace = var.namespace
110-
})
110+
}),
111+
var.mongodb_exporter_values
111112
]
112113
}

0 commit comments

Comments
 (0)