Skip to content

Commit 437b290

Browse files
Merge pull request #15 from ns-squareops/main
added affinity and resource request and limit for backup and restore job
2 parents e149bf4 + efb1b7a commit 437b290

File tree

10 files changed

+175
-3
lines changed

10 files changed

+175
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module "aws" {
4848
cluster_name = "prod-eks"
4949
environment = "prod"
5050
name = "mysql"
51+
namespace = local.namespace
5152
store_password_to_secret_manager = true
5253
mysqldb_custom_credentials_enabled = true
5354
mysqldb_custom_credentials_config = {
@@ -153,6 +154,9 @@ No modules.
153154
| Name | Description | Type | Default | Required |
154155
|------|-------------|------|---------|:--------:|
155156
| <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 |
157+
| <a name="input_azure_container_name"></a> [azure\_container\_name](#input\_azure\_container\_name) | Azure container name | `string` | `""` | no |
158+
| <a name="input_azure_storage_account_key"></a> [azure\_storage\_account\_key](#input\_azure\_storage\_account\_key) | Azure storage account key | `string` | `""` | no |
159+
| <a name="input_azure_storage_account_name"></a> [azure\_storage\_account\_name](#input\_azure\_storage\_account\_name) | Azure storage account name | `string` | `""` | no |
156160
| <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 |
157161
| <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 |
158162
| <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 |
@@ -163,7 +167,7 @@ No modules.
163167
| <a name="input_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#input\_metric\_exporter\_pasword) | Metric exporter password for MongoDB | `string` | `""` | no |
164168
| <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> "bucket_uri": "",<br> "cron_for_full_backup": "",<br> "s3_bucket_region": ""<br>}</pre> | no |
165169
| <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 |
166-
| <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> "store_password_to_secret_manager": true,<br> "values_yaml": ""<br>}</pre> | no |
170+
| <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_database": "",<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> "store_password_to_secret_manager": true,<br> "values_yaml": ""<br>}</pre> | no |
167171
| <a name="input_mysqldb_custom_credentials_config"></a> [mysqldb\_custom\_credentials\_config](#input\_mysqldb\_custom\_credentials\_config) | Specify the configuration settings for MySQL to pass custom credentials during creation | `any` | <pre>{<br> "custom_user_password": "",<br> "custom_username": "",<br> "exporter_password": "",<br> "exporter_user": "",<br> "replication_password": "",<br> "replication_user": "",<br> "root_password": "",<br> "root_user": ""<br>}</pre> | no |
168172
| <a name="input_mysqldb_custom_credentials_enabled"></a> [mysqldb\_custom\_credentials\_enabled](#input\_mysqldb\_custom\_credentials\_enabled) | Specifies whether to enable custom credentials for MySQL database. | `bool` | `false` | no |
169173
| <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 |
@@ -173,6 +177,8 @@ No modules.
173177
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Name of the Kubernetes namespace where the MYSQL deployment will be deployed. | `string` | `"mysqldb"` | no |
174178
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Google Cloud project ID | `string` | `""` | no |
175179
| <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 |
180+
| <a name="input_resource_group_location"></a> [resource\_group\_location](#input\_resource\_group\_location) | Azure region | `string` | `"East US"` | no |
181+
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Azure Resource Group name | `string` | `""` | no |
176182
| <a name="input_root_password"></a> [root\_password](#input\_root\_password) | Root password for MongoDB | `string` | `""` | no |
177183
| <a name="input_service_account_backup"></a> [service\_account\_backup](#input\_service\_account\_backup) | Service account for backup (GCP) | `string` | `""` | no |
178184
| <a name="input_service_account_restore"></a> [service\_account\_restore](#input\_service\_account\_restore) | Service account for restore (GCP) | `string` | `""` | no |

examples/complete/aws/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_aws"></a> [aws](#module\_aws) | squareops/mysql/kubernetes//provider/aws | n/a |
25+
| <a name="module_aws"></a> [aws](#module\_aws) | squareops/mysql/kubernetes//modules/resources/aws | n/a |
2626
| <a name="module_mysql"></a> [mysql](#module\_mysql) | squareops/mysql/kubernetes | n/a |
2727

2828
## Resources

examples/complete/aws/helm/values.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,30 @@ secondary:
1919
operator: In
2020
values:
2121
- "true"
22+
23+
affinity:
24+
nodeAffinity:
25+
requiredDuringSchedulingIgnoredDuringExecution:
26+
nodeSelectorTerms:
27+
- matchExpressions:
28+
- key: "Infra-Services"
29+
operator: In
30+
values:
31+
- "true"
32+
backupjob:
33+
resources:
34+
requests:
35+
memory: 100Mi
36+
cpu: 50m
37+
limits:
38+
memory: 200Mi
39+
cpu: 100m
40+
41+
restorejob:
42+
resources:
43+
requests:
44+
memory: 100Mi
45+
cpu: 50m
46+
limits:
47+
memory: 200Mi
48+
cpu: 100m

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_mysql_credential"></a> [mysql\_credential](#output\_mysql\_credential) | MySQL credentials used for accessing the MySQL database. |
4242
| <a name="output_mysql_endpoints"></a> [mysql\_endpoints](#output\_mysql\_endpoints) | MySQL 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/mysql/kubernetes//modules/resources/azure | n/a |
59+
| <a name="module_mysql"></a> [mysql](#module\_mysql) | squareops/mysql/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_mysql_credential"></a> [mysql\_credential](#output\_mysql\_credential) | MySQL credentials used for accessing the MySQL database. |
76+
| <a name="output_mysql_endpoints"></a> [mysql\_endpoints](#output\_mysql\_endpoints) | MySQL 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/mysql/kubernetes//provider/gcp | n/a |
25+
| <a name="module_gcp"></a> [gcp](#module\_gcp) | squareops/mysql/kubernetes//modules/resources/gcp | n/a |
2626
| <a name="module_mysql"></a> [mysql](#module\_mysql) | squareops/mysql/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
@@ -12,3 +12,22 @@ auth:
1212
username: "${custom_user_username}"
1313

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

helm/values/restore/values.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,22 @@ annotations:
1010
${annotations}
1111

1212
bucket_provider_type: ${bucket_provider_type}
13+
14+
affinity:
15+
nodeAffinity:
16+
requiredDuringSchedulingIgnoredDuringExecution:
17+
nodeSelectorTerms:
18+
- matchExpressions:
19+
- key: "Infra-Services"
20+
operator: In
21+
values:
22+
- "true"
23+
24+
restorejob:
25+
resources:
26+
requests:
27+
memory: 100Mi
28+
cpu: 50m
29+
limits:
30+
memory: 200Mi
31+
cpu: 100m

modules/backup/templates/cronjob.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ spec:
1313
spec:
1414
template:
1515
spec:
16+
affinity: {{ .Values.affinity | toYaml | nindent 10 }}
1617
restartPolicy: OnFailure
1718
imagePullSecrets:
1819
- name: regcred
@@ -40,3 +41,4 @@ spec:
4041
value: "s3"
4142
- name: AWS_DEFAULT_REGION
4243
value: {{ .Values.backup.aws_default_region }}
44+
resources: {{ .Values.backupjob.resources | toYaml | nindent 12 }}

modules/resources/azure/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,65 @@ No modules.
6060
| <a name="output_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#output\_metric\_exporter\_pasword) | mysqldb\_exporter user's password of mysqldb |
6161
| <a name="output_mysqldb_replication_user_password"></a> [mysqldb\_replication\_user\_password](#output\_mysqldb\_replication\_user\_password) | replicator user's password of mysqldb |
6262
| <a name="output_root_password"></a> [root\_password](#output\_root\_password) | Root user's password of mysqldb |
63+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
64+
## Requirements
65+
66+
No requirements.
67+
68+
## Providers
69+
70+
| Name | Version |
71+
|------|---------|
72+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | n/a |
73+
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
74+
75+
## Modules
76+
77+
No modules.
78+
79+
## Resources
80+
81+
| Name | Type |
82+
|------|------|
83+
| [azurerm_key_vault.mysql-secret](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault) | resource |
84+
| [azurerm_key_vault_secret.mysql-secret](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
85+
| [azurerm_role_assignment.pod_identity_assignment_backup](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
86+
| [azurerm_role_assignment.secretadmin_backup](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
87+
| [azurerm_role_assignment.secretadmin_restore](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
88+
| [azurerm_role_assignment.service_account_token_creator_backup](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
89+
| [azurerm_role_assignment.service_account_token_creator_restore](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
90+
| [azurerm_user_assigned_identity.mysql_backup_identity](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
91+
| [azurerm_user_assigned_identity.mysql_restore_identity](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
92+
| [azurerm_user_assigned_identity.pod_identity_backup](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
93+
| [random_password.mysqldb_custom_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
94+
| [random_password.mysqldb_exporter_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
95+
| [random_password.mysqldb_replication_user_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
96+
| [random_password.mysqldb_root_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
97+
| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source |
98+
| [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |
99+
100+
## Inputs
101+
102+
| Name | Description | Type | Default | Required |
103+
|------|-------------|------|---------|:--------:|
104+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the Azure AKS cluster | `string` | `""` | no |
105+
| <a name="input_custom_user_username"></a> [custom\_user\_username](#input\_custom\_user\_username) | n/a | `string` | `""` | no |
106+
| <a name="input_environment"></a> [environment](#input\_environment) | Environment in which the infrastructure is being deployed (e.g., production, staging, development) | `string` | `"test"` | no |
107+
| <a name="input_mysqldb_custom_credentials_config"></a> [mysqldb\_custom\_credentials\_config](#input\_mysqldb\_custom\_credentials\_config) | Specify the configuration settings for MySQL to pass custom credentials during creation | `any` | <pre>{<br> "custom_user_password": "",<br> "custom_username": "",<br> "exporter_password": "",<br> "exporter_user": "",<br> "replication_password": "",<br> "replication_user": "",<br> "root_password": "",<br> "root_user": ""<br>}</pre> | no |
108+
| <a name="input_mysqldb_custom_credentials_enabled"></a> [mysqldb\_custom\_credentials\_enabled](#input\_mysqldb\_custom\_credentials\_enabled) | Specifies whether to enable custom credentials for MySQL database. | `bool` | `false` | no |
109+
| <a name="input_name"></a> [name](#input\_name) | Name identifier for module to be added as suffix to resources | `string` | `"test"` | no |
110+
| <a name="input_resource_group_location"></a> [resource\_group\_location](#input\_resource\_group\_location) | Azure region | `string` | `"East US"` | no |
111+
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Azure Resource Group name | `string` | `""` | no |
112+
| <a name="input_storage_account_name"></a> [storage\_account\_name](#input\_storage\_account\_name) | n/a | `string` | `""` | no |
113+
| <a name="input_storage_resource_group_name"></a> [storage\_resource\_group\_name](#input\_storage\_resource\_group\_name) | Azure Storage account Resource Group name | `string` | `""` | no |
114+
| <a name="input_store_password_to_secret_manager"></a> [store\_password\_to\_secret\_manager](#input\_store\_password\_to\_secret\_manager) | Specifies whether to store the credentials in GCP secret manager. | `bool` | `false` | no |
115+
116+
## Outputs
117+
118+
| Name | Description |
119+
|------|-------------|
120+
| <a name="output_custom_user_password"></a> [custom\_user\_password](#output\_custom\_user\_password) | custom user's password of mysqldb |
121+
| <a name="output_metric_exporter_pasword"></a> [metric\_exporter\_pasword](#output\_metric\_exporter\_pasword) | mysqldb\_exporter user's password of mysqldb |
122+
| <a name="output_mysqldb_replication_user_password"></a> [mysqldb\_replication\_user\_password](#output\_mysqldb\_replication\_user\_password) | replicator user's password of mysqldb |
123+
| <a name="output_root_password"></a> [root\_password](#output\_root\_password) | Root user's password of mysqldb |
124+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/restore/templates/job.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
spec:
66
template:
77
spec:
8+
affinity: {{ .Values.affinity | toYaml | nindent 6 }}
89
serviceAccountName: sa-mysql-restore
910
containers:
1011
- name: restore-mysqldb
@@ -31,5 +32,6 @@ spec:
3132
value: {{ .Values.bucket_provider_type}}
3233
- name: AWS_DEFAULT_REGION
3334
value: {{ .Values.restore.aws_default_region}}
35+
resources: {{ .Values.restorejob.resources | toYaml | nindent 12 }}
3436
restartPolicy: Never
3537
backoffLimit: 4

0 commit comments

Comments
 (0)