Skip to content

Commit 97882e1

Browse files
authored
enhancement: Added var to enable HA mode for notification service (#172)
1 parent b190bc7 commit 97882e1

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

templates/kubernetes/terraform/environments/prod/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,6 @@ module "kubernetes" {
8282
# This domain or address must be verified by the mail provider (Sendgrid, SES, etc.)
8383
user_auth_mail_from_address = "noreply@${local.domain_name}"
8484

85-
notification_service_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
85+
notification_service_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
86+
notification_service_highly_available = true
8687
}

templates/kubernetes/terraform/environments/stage/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ module "kubernetes" {
8181
# This domain or address must be verified by the mail provider (Sendgrid, SES, etc.)
8282
user_auth_mail_from_address = "noreply@${local.domain_name}"
8383

84-
notification_service_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
84+
notification_service_enabled = <%if eq (index .Params `sendgridApiKey`) "" %>false<% else %>true<% end %>
85+
notification_service_highly_available = false
8586
}

templates/kubernetes/terraform/modules/kubernetes/notification_service.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ resource "helm_release" "notification_service" {
3232
value = "true"
3333
}
3434

35+
set {
36+
name = "autoscaling.enabled"
37+
value = var.notification_service_highly_available ? "true" : "false" # If false, deployment replicas will be set to 1 and the replica options below will be ignored
38+
}
39+
set {
40+
name = "autoscaling.minReplicas"
41+
value = var.notification_service_highly_available ? "2" : "1"
42+
}
43+
set {
44+
name = "autoscaling.maxReplicas"
45+
value = var.notification_service_highly_available ? "4" : "2"
46+
}
47+
3548
# This will become a secret provided as an env var
3649
set_sensitive {
3750
name = "application.sendgridApiKey"

templates/kubernetes/terraform/modules/kubernetes/variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ variable "user_auth_mail_from_address" {
132132

133133
variable "notification_service_enabled" {
134134
description = "If enabled, will install the Zero notification service in the cluster to enable easy implementation of notification via email, sms, push, etc."
135-
type = string
136-
default = "false"
135+
type = bool
136+
default = false
137+
}
138+
139+
variable "notification_service_highly_available" {
140+
description = "If enabled, will make sure a minimum of 2 pods are running and use a horizontal pod autoscaler to make scale the number of pods based on CPU. Recommended for Production."
141+
type = bool
142+
default = true
137143
}

0 commit comments

Comments
 (0)