Skip to content

Commit 99ff012

Browse files
committed
added app version, namespace enable/disable param
1 parent f1a2b92 commit 99ff012

File tree

7 files changed

+37
-26
lines changed

7 files changed

+37
-26
lines changed

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 = false
11+
namespace = ""
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 = false
11+
namespace = ""
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 = false
11+
namespace = ""
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: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ resource "helm_release" "redis" {
1212
chart = "redis"
1313
version = var.chart_version
1414
timeout = 600
15-
namespace = var.namespace
15+
namespace = var.create_namespace ? var.namespace : "default"
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.create_namespace ? var.namespace : "default"
2728
}),
2829
var.redis_config.values_yaml
2930
]

output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ output "redis_endpoints" {
22
description = "Redis endpoints in the Kubernetes cluster."
33
value = {
44
redis_port = "6379",
5-
redis_master_endpoint = "redis-master.${var.namespace}.svc.cluster.local",
6-
redis_slave_endpoint = "redis-replicas.${var.namespace}.svc.cluster.local"
5+
redis_master_endpoint = var.create_namespace ? "redis-master.${var.namespace}.svc.cluster.local" : "redis-master.default.svc.cluster.local",
6+
redis_slave_endpoint = var.create_namespace ? "redis-replicas.${var.namespace}.svc.cluster.local" : "redis-replicas.default.svc.cluster.local"
77
}
88
}
99

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)