Skip to content

Commit 9ca7c83

Browse files
Merge pull request #8 from ShibraAmin18/gcp
1. Added Azure and GCP cloud Compatibility 2. Enhanced Security: a. Credential Storage and Retrieval
2 parents d7c5ee1 + 51305c5 commit 9ca7c83

File tree

31 files changed

+805
-98
lines changed

31 files changed

+805
-98
lines changed

IAM.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## IAM Permission
1+
## AWS IAM Permission
22

33
The Policy required to deploy this module:
44
```hcl
@@ -33,3 +33,17 @@ The Policy required to deploy this module:
3333
]
3434
}
3535
```
36+
## Azure Role Permissions
37+
38+
```hcl
39+
permissions {
40+
actions = [
41+
"Microsoft.KeyVault/locations/deletedVaults/read",
42+
"Microsoft.KeyVault/vaults/delete",
43+
"Microsoft.KeyVault/vaults/read",
44+
"Microsoft.KeyVault/vaults/write",
45+
"Microsoft.Resources/subscriptions/providers/read",
46+
"Microsoft.Resources/subscriptions/resourcegroups/read"]
47+
not_actions = []
48+
}
49+
```

README.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,77 @@
66

77
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
88
<br>
9-
This module allows users to customize the deployment by providing various input variables. Users can specify the name and environment of the Redis deployment, the chart and app version, the namespace in which the Redis deployment will be created, and whether to enable Grafana monitoring. The module also allows users to set the recovery window for the AWS Secrets Manager that is used to store the Redis password.
9+
This module allows users to customize the deployment by providing various input variables. Users can specify the name and environment of the Redis deployment, the chart and app version, the namespace in which the Redis deployment will be created, and whether to enable Grafana monitoring. This module provides options to create a new namespace, and to configure recovery windows for AWS Secrets Manager, Azure key vault & GCP secrets manager. With this module, users can easily deploy a highly available redis on AWS EKS, Azure AKS & GCP GKE Kubernetes clusters with the flexibility to customize their configurations according to their needs.
1010
<br><br>
1111
This module creates a Redis master and one or more Redis slaves, depending on the specified architecture. The module creates Kubernetes services for the Redis master and slave deployments, and exposes these services as endpoints that can be used to connect to the Redis database. Users can retrieve these endpoints using the module's outputs.
1212

1313
## Supported Versions :
1414

15-
| Redis Helm Chart Version | K8s supported version |
15+
| Redis Helm Chart Version | K8s supported version (EKS, AKS & GKE) |
1616
| :-----: | :--- |
1717
| **16.13.2** | **1.23,1.24,1.25,1.26,1.27** |
1818

1919
## Usage Example
2020

2121
```hcl
22+
locals {
23+
name = "redis"
24+
region = "eastus"
25+
environment = "prod"
26+
additional_tags = {
27+
Owner = "organization_name"
28+
Expires = "Never"
29+
Department = "Engineering"
30+
}
31+
create_namespace = true
32+
namespace = "redis"
33+
store_password_to_secret_manager = true
34+
custom_credentials_enabled = true
35+
custom_credentials_config = {
36+
password = "aajdhgduy3873683dh"
37+
}
38+
}
39+
40+
module "azure" {
41+
source = "squareops/redis/kubernetes//modules/resources/azure"
42+
resource_group_name = "prod-skaf-rg"
43+
resource_group_location = local.region
44+
environment = local.environment
45+
name = local.name
46+
store_password_to_secret_manager = local.store_password_to_secret_manager
47+
custom_credentials_enabled = local.custom_credentials_enabled
48+
custom_credentials_config = local.custom_credentials_config
49+
}
50+
2251
module "redis" {
23-
source = "squareops/redis/kubernetes"
52+
source = "squareops/redis/kubernetes"
53+
create_namespace = local.create_namespace
54+
namespace = local.namespace
2455
redis_config = {
25-
name = "redis"
56+
name = local.name
2657
values_yaml = ""
27-
environment = "prod"
58+
environment = local.environment
59+
app_version = "6.2.7-debian-11-r11"
2860
architecture = "replication"
2961
slave_volume_size = "10Gi"
3062
master_volume_size = "10Gi"
31-
storage_class_name = "gp3"
63+
storage_class_name = "infra-service-sc"
3264
slave_replica_count = 2
33-
store_password_to_secret_manager = true
65+
store_password_to_secret_manager = local.store_password_to_secret_manager
66+
secret_provider_type = "azure"
3467
}
3568
grafana_monitoring_enabled = true
36-
recovery_window_aws_secret = 0
37-
custom_credentials_enabled = true
38-
custom_credentials_config = {
39-
password = "aajdhgduy3873683dh"
40-
}
69+
custom_credentials_enabled = local.custom_credentials_enabled
70+
custom_credentials_config = local.custom_credentials_config
71+
redis_password = local.custom_credentials_enabled ? "" : module.azure.redis_password
4172
}
4273
74+
75+
4376
```
44-
Refer [examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete) for more details.
77+
- Refer [AWS examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete/aws) for more details.
78+
- Refer [Azure examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete/azure) for more details.
79+
- Refer [GCP examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete/gcp) for more details.
4580

4681
## IAM Permissions
4782
The required IAM permissions to create resources from this module can be found [here](https://github.com/squareops/terraform-kubernetes-redis/blob/main/IAM.md)
@@ -54,7 +89,7 @@ The required IAM permissions to create resources from this module can be found [
5489
5. To deploy Prometheus/Grafana, please follow the installation instructions for each tool in their respective documentation.
5590
6. Once Prometheus and Grafana are deployed, the exporter can be configured to scrape metrics data from your application or system and send it to Prometheus.
5691
7. Finally, you can use Grafana to create custom dashboards and visualize the metrics data collected by Prometheus.
57-
8. This module is compatible with EKS version 1.23, which is great news for users deploying the module on an EKS cluster running that version. Review the module's documentation, meet specific configuration requirements, and test thoroughly after deployment to ensure everything works as expected.
92+
8. This module is compatible with EKS, AKS & GKE which is great news for users deploying the module on an AWS, Azure & GCP cloud. Review the module's documentation, meet specific configuration requirements, and test thoroughly after deployment to ensure everything works as expected.
5893
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5994
## Requirements
6095

@@ -64,10 +99,8 @@ No requirements.
6499

65100
| Name | Version |
66101
|------|---------|
67-
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
68102
| <a name="provider_helm"></a> [helm](#provider\_helm) | n/a |
69103
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
70-
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
71104

72105
## Modules
73106

@@ -77,11 +110,8 @@ No modules.
77110

78111
| Name | Type |
79112
|------|------|
80-
| [aws_secretsmanager_secret.redis_password](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
81-
| [aws_secretsmanager_secret_version.redis_password](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
82113
| [helm_release.redis](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
83114
| [kubernetes_namespace.redis](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
84-
| [random_password.redis_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
85115

86116
## Inputs
87117

@@ -95,7 +125,8 @@ No modules.
95125
| <a name="input_grafana_monitoring_enabled"></a> [grafana\_monitoring\_enabled](#input\_grafana\_monitoring\_enabled) | Specify whether or not to deploy Redis exporter to collect Redis metrics for monitoring in Grafana. | `bool` | `false` | no |
96126
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace where the Redis resources will be deployed. | `string` | `"redis"` | no |
97127
| <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 it can delete the secret. The value can be 0 to force deletion without recovery, or a range from 7 to 30 days. | `number` | `0` | no |
98-
| <a name="input_redis_config"></a> [redis\_config](#input\_redis\_config) | Specify the configuration settings for Redis, including the name, environment, storage options, replication settings, store password to secret manager and custom YAML values. | `any` | <pre>{<br> "architecture": "replication",<br> "environment": "",<br> "master_volume_size": "",<br> "name": "",<br> "slave_replica_count": 1,<br> "slave_volume_size": "",<br> "storage_class_name": "",<br> "store_password_to_secret_manager": "",<br> "values_yaml": ""<br>}</pre> | no |
128+
| <a name="input_redis_config"></a> [redis\_config](#input\_redis\_config) | Specify the configuration settings for Redis, including the name, environment, storage options, replication settings, store password to secret manager and custom YAML values. | `any` | <pre>{<br> "architecture": "replication",<br> "environment": "",<br> "master_volume_size": "",<br> "name": "",<br> "slave_replica_count": 1,<br> "slave_volume_size": "",<br> "storage_class_name": "",<br> "store_password_to_secret_manager": true,<br> "values_yaml": ""<br>}</pre> | no |
129+
| <a name="input_redis_password"></a> [redis\_password](#input\_redis\_password) | n/a | `string` | `""` | no |
99130

100131
## Outputs
101132

examples/complete/README.md renamed to examples/complete/aws/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
77
<br>
88
This example will be very useful for users who are new to a module and want to quickly learn how to use it. By reviewing the examples, users can gain a better understanding of how the module works, what features it supports, and how to customize it to their specific needs.
9+
910
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1011
## Requirements
1112

@@ -16,7 +17,6 @@ No requirements.
1617
| Name | Version |
1718
|------|---------|
1819
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
19-
2020
## Modules
2121

2222
| Name | Source | Version |
@@ -29,6 +29,8 @@ No requirements.
2929
|------|------|
3030
| [aws_eks_cluster.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) | data source |
3131
| [aws_eks_cluster_auth.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
32+
| [google_client_config.default](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source |
33+
| [google_container_cluster.primary](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/container_cluster) | data source |
3234

3335
## Inputs
3436

File renamed without changes.

examples/complete/aws/main.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
locals {
2+
name = "redis"
3+
region = "us-east-2"
4+
environment = "prod"
5+
additional_tags = {
6+
Owner = "organization_name"
7+
Expires = "Never"
8+
Department = "Engineering"
9+
}
10+
create_namespace = true
11+
namespace = "redis"
12+
store_password_to_secret_manager = false
13+
custom_credentials_enabled = true
14+
custom_credentials_config = {
15+
password = "aajdhgduy3873683dh"
16+
}
17+
}
18+
19+
module "aws" {
20+
source = "squareops/redis/kubernetes//modules/resources/aws"
21+
environment = local.environment
22+
name = local.name
23+
store_password_to_secret_manager = local.store_password_to_secret_manager
24+
custom_credentials_enabled = local.custom_credentials_enabled
25+
custom_credentials_config = local.custom_credentials_config
26+
}
27+
28+
module "redis" {
29+
source = "squareops/redis/kubernetes"
30+
create_namespace = local.create_namespace
31+
namespace = local.namespace
32+
redis_config = {
33+
name = local.name
34+
values_yaml = file("./helm/values.yaml")
35+
environment = local.environment
36+
app_version = "6.2.7-debian-11-r11"
37+
architecture = "replication"
38+
slave_volume_size = "10Gi"
39+
master_volume_size = "10Gi"
40+
storage_class_name = "gp2"
41+
slave_replica_count = 2
42+
store_password_to_secret_manager = local.store_password_to_secret_manager
43+
secret_provider_type = "aws"
44+
}
45+
grafana_monitoring_enabled = true
46+
custom_credentials_enabled = local.custom_credentials_enabled
47+
custom_credentials_config = local.custom_credentials_config
48+
redis_password = local.custom_credentials_enabled ? "" : module.aws.redis_password
49+
}
File renamed without changes.
File renamed without changes.

examples/complete/azure/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Redis Example
2+
![squareops_avatar]
3+
4+
[squareops_avatar]: https://squareops.com/wp-content/uploads/2022/12/squareops-logo.png
5+
6+
### [SquareOps Technologies](https://squareops.com/) Your DevOps Partner for Accelerating cloud journey.
7+
<br>
8+
This example will be very useful for users who are new to a module and want to quickly learn how to use it. By reviewing the examples, users can gain a better understanding of how the module works, what features it supports, and how to customize it to their specific needs.
9+
10+
<!-- BEGIN_TF_DOCS -->
11+
## Requirements
12+
13+
No requirements.
14+
15+
## Providers
16+
17+
| Name | Version |
18+
|------|---------|
19+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.70.0 |
20+
21+
## Modules
22+
23+
| Name | Source | Version |
24+
|------|--------|---------|
25+
| <a name="module_azure"></a> [azure](#module\_azure) | squareops/redis/kubernetes//modules/resources/azure | n/a |
26+
| <a name="module_redis"></a> [redis](#module\_redis) | squareops/redis/kubernetes | n/a |
27+
28+
## Resources
29+
30+
| Name | Type |
31+
|------|------|
32+
| [azurerm_kubernetes_cluster.primary](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/kubernetes_cluster) | data source |
33+
34+
## Inputs
35+
36+
No inputs.
37+
38+
## Outputs
39+
40+
| Name | Description |
41+
|------|-------------|
42+
| <a name="output_redis_credential"></a> [redis\_credential](#output\_redis\_credential) | Redis credentials used for accessing the database. |
43+
| <a name="output_redis_endpoints"></a> [redis\_endpoints](#output\_redis\_endpoints) | Redis endpoints in the Kubernetes cluster. |
44+
<!-- END_TF_DOCS -->
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
master:
2+
affinity:
3+
nodeAffinity:
4+
requiredDuringSchedulingIgnoredDuringExecution:
5+
nodeSelectorTerms:
6+
- matchExpressions:
7+
- key: "Addons-Services"
8+
operator: In
9+
values:
10+
- "true"
11+
12+
replica:
13+
affinity:
14+
nodeAffinity:
15+
requiredDuringSchedulingIgnoredDuringExecution:
16+
nodeSelectorTerms:
17+
- matchExpressions:
18+
- key: "Addons-Services"
19+
operator: In
20+
values:
21+
- "true"

examples/complete/azure/main.tf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
locals {
2+
name = "redis"
3+
region = "eastus"
4+
environment = "prod"
5+
additional_tags = {
6+
Owner = "organization_name"
7+
Expires = "Never"
8+
Department = "Engineering"
9+
}
10+
create_namespace = true
11+
namespace = "redis"
12+
store_password_to_secret_manager = true
13+
custom_credentials_enabled = true
14+
custom_credentials_config = {
15+
password = "aajdhgduy3873683dh"
16+
}
17+
}
18+
19+
module "azure" {
20+
source = "squareops/redis/kubernetes//modules/resources/azure"
21+
resource_group_name = "prod-skaf-rg"
22+
resource_group_location = local.region
23+
environment = local.environment
24+
name = local.name
25+
store_password_to_secret_manager = local.store_password_to_secret_manager
26+
custom_credentials_enabled = local.custom_credentials_enabled
27+
custom_credentials_config = local.custom_credentials_config
28+
}
29+
30+
module "redis" {
31+
source = "squareops/redis/kubernetes"
32+
create_namespace = local.create_namespace
33+
namespace = local.namespace
34+
redis_config = {
35+
name = local.name
36+
values_yaml = file("./helm/values.yaml")
37+
environment = local.environment
38+
app_version = "6.2.7-debian-11-r11"
39+
architecture = "replication"
40+
slave_volume_size = "10Gi"
41+
master_volume_size = "10Gi"
42+
storage_class_name = "infra-service-sc"
43+
slave_replica_count = 2
44+
store_password_to_secret_manager = local.store_password_to_secret_manager
45+
secret_provider_type = "azure"
46+
}
47+
grafana_monitoring_enabled = true
48+
custom_credentials_enabled = local.custom_credentials_enabled
49+
custom_credentials_config = local.custom_credentials_config
50+
redis_password = local.custom_credentials_enabled ? "" : module.azure.redis_password
51+
}

0 commit comments

Comments
 (0)