Skip to content

Commit 51305c5

Browse files
authored
Merge pull request #3 from Ad-squareops/gcp
added app version, namespace enable/disable param
2 parents f1a2b92 + 9c78d18 commit 51305c5

File tree

7 files changed

+72
-40
lines changed

7 files changed

+72
-40
lines changed

README.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,60 @@ This module creates a Redis master and one or more Redis slaves, depending on th
1919
## Usage Example
2020

2121
```hcl
22-
module "aws" {
23-
source = "squareops/redis/kubernetes//modules/resources/aws"
24-
environment = "prod"
25-
name = "redis"
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"
2633
store_password_to_secret_manager = true
2734
custom_credentials_enabled = true
28-
custom_credentials_config = {
35+
custom_credentials_config = {
2936
password = "aajdhgduy3873683dh"
3037
}
3138
}
3239
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+
3351
module "redis" {
34-
source = "squareops/redis/kubernetes"
52+
source = "squareops/redis/kubernetes"
53+
create_namespace = local.create_namespace
54+
namespace = local.namespace
3555
redis_config = {
36-
name = "redis"
37-
values_yaml = file("./helm/values.yaml")
38-
environment = "prod"
56+
name = local.name
57+
values_yaml = ""
58+
environment = local.environment
59+
app_version = "6.2.7-debian-11-r11"
3960
architecture = "replication"
4061
slave_volume_size = "10Gi"
4162
master_volume_size = "10Gi"
42-
storage_class_name = "gp3"
63+
storage_class_name = "infra-service-sc"
4364
slave_replica_count = 2
44-
store_password_to_secret_manager = true
45-
secret_provider_type = "aws"
65+
store_password_to_secret_manager = local.store_password_to_secret_manager
66+
secret_provider_type = "azure"
4667
}
4768
grafana_monitoring_enabled = true
48-
custom_credentials_enabled = true
49-
custom_credentials_config = {
50-
password = "aajdhgduy3873683dh"
51-
}
52-
redis_password = true ? "" : module.aws.redis_password
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
5372
}
5473
74+
75+
5576
```
5677
- Refer [AWS examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete/aws) for more details.
5778
- Refer [Azure examples](https://github.com/squareops/terraform-kubernetes-redis/tree/main/examples/complete/azure) for more details.

examples/complete/aws/main.tf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ locals {
77
Expires = "Never"
88
Department = "Engineering"
99
}
10-
store_password_to_secret_manager = true
11-
custom_credentials_enabled = true
10+
create_namespace = true
11+
namespace = "redis"
12+
store_password_to_secret_manager = false
13+
custom_credentials_enabled = true
1214
custom_credentials_config = {
1315
password = "aajdhgduy3873683dh"
1416
}
@@ -24,21 +26,24 @@ module "aws" {
2426
}
2527

2628
module "redis" {
27-
source = "squareops/redis/kubernetes"
29+
source = "squareops/redis/kubernetes"
30+
create_namespace = local.create_namespace
31+
namespace = local.namespace
2832
redis_config = {
2933
name = local.name
3034
values_yaml = file("./helm/values.yaml")
3135
environment = local.environment
36+
app_version = "6.2.7-debian-11-r11"
3237
architecture = "replication"
3338
slave_volume_size = "10Gi"
3439
master_volume_size = "10Gi"
35-
storage_class_name = "gp3"
40+
storage_class_name = "gp2"
3641
slave_replica_count = 2
3742
store_password_to_secret_manager = local.store_password_to_secret_manager
3843
secret_provider_type = "aws"
3944
}
4045
grafana_monitoring_enabled = true
4146
custom_credentials_enabled = local.custom_credentials_enabled
42-
custom_credentials_config = local.custom_credentials_config
43-
redis_password = local.custom_credentials_enabled ? "" : module.aws.redis_password
47+
custom_credentials_config = local.custom_credentials_config
48+
redis_password = local.custom_credentials_enabled ? "" : module.aws.redis_password
4449
}

examples/complete/azure/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ locals {
77
Expires = "Never"
88
Department = "Engineering"
99
}
10+
create_namespace = true
11+
namespace = "redis"
1012
store_password_to_secret_manager = true
1113
custom_credentials_enabled = true
1214
custom_credentials_config = {
@@ -26,11 +28,14 @@ module "azure" {
2628
}
2729

2830
module "redis" {
29-
source = "squareops/redis/kubernetes"
31+
source = "squareops/redis/kubernetes"
32+
create_namespace = local.create_namespace
33+
namespace = local.namespace
3034
redis_config = {
3135
name = local.name
3236
values_yaml = file("./helm/values.yaml")
3337
environment = local.environment
38+
app_version = "6.2.7-debian-11-r11"
3439
architecture = "replication"
3540
slave_volume_size = "10Gi"
3641
master_volume_size = "10Gi"

examples/complete/gcp/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ locals {
77
Expires = "Never"
88
Department = "Engineering"
99
}
10+
create_namespace = true
11+
namespace = "redis"
1012
store_password_to_secret_manager = true
1113
custom_credentials_enabled = true
1214
custom_credentials_config = {
@@ -25,11 +27,14 @@ module "gcp" {
2527
}
2628

2729
module "redis" {
28-
source = "squareops/redis/kubernetes"
30+
source = "squareops/redis/kubernetes"
31+
create_namespace = local.create_namespace
32+
namespace = local.namespace
2933
redis_config = {
3034
name = local.name
3135
values_yaml = file("./helm/values.yaml")
3236
environment = local.environment
37+
app_version = "6.2.7-debian-11-r11"
3338
architecture = "replication"
3439
slave_volume_size = "10Gi"
3540
master_volume_size = "10Gi"

helm/values/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ metrics:
14591459
enabled: true
14601460
## @param metrics.serviceMonitor.namespace The namespace in which the ServiceMonitor will be created
14611461
##
1462-
namespace: ""
1462+
namespace: "${service_monitor_namespace}"
14631463
## @param metrics.serviceMonitor.interval The interval at which metrics should be scraped
14641464
##
14651465
interval: 30s

main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ resource "helm_release" "redis" {
1616
repository = "https://charts.bitnami.com/bitnami"
1717
values = [
1818
templatefile("${path.module}/helm/values/values.yaml", {
19-
app_version = var.app_version,
20-
architecture = var.redis_config.architecture,
21-
redis_password = var.custom_credentials_enabled ? var.custom_credentials_config.password : var.redis_password,
22-
slave_volume_size = var.redis_config.slave_volume_size,
23-
slave_replicacount = var.redis_config.slave_replica_count,
24-
storage_class_name = var.redis_config.storage_class_name,
25-
redis_exporter_enabled = var.grafana_monitoring_enabled,
26-
redis_master_volume_size = var.redis_config.master_volume_size
19+
app_version = var.redis_config.app_version,
20+
architecture = var.redis_config.architecture,
21+
redis_password = var.custom_credentials_enabled ? var.custom_credentials_config.password : var.redis_password,
22+
slave_volume_size = var.redis_config.slave_volume_size,
23+
slave_replicacount = var.redis_config.slave_replica_count,
24+
storage_class_name = var.redis_config.storage_class_name,
25+
redis_exporter_enabled = var.grafana_monitoring_enabled,
26+
redis_master_volume_size = var.redis_config.master_volume_size,
27+
service_monitor_namespace = var.namespace
2728
}),
2829
var.redis_config.values_yaml
2930
]

variables.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variable "redis_config" {
55
environment = ""
66
master_volume_size = ""
77
architecture = "replication"
8+
app_version = "6.2.7-debian-11-r11"
89
slave_replica_count = 1
910
slave_volume_size = ""
1011
storage_class_name = ""
@@ -20,12 +21,6 @@ variable "chart_version" {
2021
description = "Version of the chart for the Redis application that will be deployed."
2122
}
2223

23-
variable "app_version" {
24-
type = string
25-
default = "6.2.7-debian-11-r11"
26-
description = "Version of the Redis application that will be deployed."
27-
}
28-
2924
variable "namespace" {
3025
type = string
3126
default = "redis"

0 commit comments

Comments
 (0)