Skip to content

Commit

Permalink
fix(DMVP-6036): have flagger notify/alerts configure ability
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdntgrn committed Nov 14, 2024
1 parent 92b3733 commit 10f1343
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ worker_groups = {
| <a name="input_enable_waf_for_alb"></a> [enable\_waf\_for\_alb](#input\_enable\_waf\_for\_alb) | Enables WAF and WAF V2 addons for ALB | `bool` | `false` | no |
| <a name="input_external_dns"></a> [external\_dns](#input\_external\_dns) | Allows to install external-dns helm chart and related roles, which allows to automatically create R53 records based on ingress/service domain/host configs | <pre>object({<br> enabled = optional(bool, false)<br> configs = optional(any, {})<br> })</pre> | <pre>{<br> "enabled": false<br>}</pre> | no |
| <a name="input_external_secrets_namespace"></a> [external\_secrets\_namespace](#input\_external\_secrets\_namespace) | The namespace of external-secret operator | `string` | `"kube-system"` | no |
| <a name="input_flagger"></a> [flagger](#input\_flagger) | Allows to create/deploy flagger operator to have custom rollout strategies like canary/blue-green and also it allows to create custom flagger metric templates | <pre>object({<br> enabled = optional(bool, false)<br> namespace = optional(string, "ingress-nginx") # The flagger operator helm being installed on same namespace as mesh/ingress provider so this field need to be set based on which ingress/mesh we are going to use, more info in https://artifacthub.io/packages/helm/flagger/flagger<br> configs = optional(any, {}) # available options can be found in https://artifacthub.io/packages/helm/flagger/flagger<br> metric_template_configs = optional(any, {}) # available options can be found in https://github.com/dasmeta/helm/tree/flagger-metric-template-0.1.0/charts/flagger-metric-template<br> enable_metric_template = optional(bool, false)<br> enable_loadtester = optional(bool, false)<br> })</pre> | <pre>{<br> "enabled": false<br>}</pre> | no |
| <a name="input_flagger"></a> [flagger](#input\_flagger) | Allows to create/deploy flagger operator to have custom rollout strategies like canary/blue-green and also it allows to create custom flagger metric templates | <pre>object({<br> enabled = optional(bool, false)<br> namespace = optional(string, "ingress-nginx") # The flagger operator helm being installed on same namespace as mesh/ingress provider so this field need to be set based on which ingress/mesh we are going to use, more info in https://artifacthub.io/packages/helm/flagger/flagger<br> configs = optional(any, {}) # Available options can be found in https://artifacthub.io/packages/helm/flagger/flagger<br> metrics_and_alerts_configs = optional(any, {}) # Available options can be found in https://github.com/dasmeta/helm/tree/flagger-metrics-and-alerts-0.1.0/charts/flagger-metrics-and-alerts<br> enable_loadtester = optional(bool, false) # Whether to install flagger loadtester helm<br> })</pre> | <pre>{<br> "enabled": false<br>}</pre> | no |
| <a name="input_fluent_bit_configs"></a> [fluent\_bit\_configs](#input\_fluent\_bit\_configs) | Fluent Bit configs | <pre>object({<br> enabled = optional(string, true)<br> fluent_bit_name = optional(string, "")<br> log_group_name = optional(string, "")<br> system_log_group_name = optional(string, "")<br> log_retention_days = optional(number, 90)<br> values_yaml = optional(string, "")<br> configs = optional(object({<br> inputs = optional(string, "")<br> filters = optional(string, "")<br> outputs = optional(string, "")<br> cloudwatch_outputs_enabled = optional(bool, true)<br> }), {})<br> drop_namespaces = optional(list(string), [])<br> log_filters = optional(list(string), [])<br> additional_log_filters = optional(list(string), [])<br> kube_namespaces = optional(list(string), [])<br> image_pull_secrets = optional(list(string), [])<br> })</pre> | <pre>{<br> "additional_log_filters": [<br> "ELB-HealthChecker",<br> "Amazon-Route53-Health-Check-Service"<br> ],<br> "configs": {<br> "cloudwatch_outputs_enabled": true,<br> "filters": "",<br> "inputs": "",<br> "outputs": ""<br> },<br> "drop_namespaces": [<br> "kube-system",<br> "opentelemetry-operator-system",<br> "adot",<br> "cert-manager",<br> "opentelemetry.*",<br> "meta.*"<br> ],<br> "enabled": true,<br> "fluent_bit_name": "",<br> "image_pull_secrets": [],<br> "kube_namespaces": [<br> "kube.*",<br> "meta.*",<br> "adot.*",<br> "devops.*",<br> "cert-manager.*",<br> "git.*",<br> "opentelemetry.*",<br> "stakater.*",<br> "renovate.*"<br> ],<br> "log_filters": [<br> "kube-probe",<br> "health",<br> "prometheus",<br> "liveness"<br> ],<br> "log_group_name": "",<br> "log_retention_days": 90,<br> "system_log_group_name": "",<br> "values_yaml": ""<br>}</pre> | no |
| <a name="input_manage_aws_auth"></a> [manage\_aws\_auth](#input\_manage\_aws\_auth) | n/a | `bool` | `true` | no |
| <a name="input_map_roles"></a> [map\_roles](#input\_map\_roles) | Additional IAM roles to add to the aws-auth configmap. | <pre>list(object({<br> rolearn = string<br> username = string<br> groups = list(string)<br> }))</pre> | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion examples/eks-fluent-bit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.41 |

## Modules

Expand Down
28 changes: 27 additions & 1 deletion examples/eks-with-flagger/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,33 @@ module "this" {
prometheus = {
install = true
}
# slack = { # (optional) enable global flagger slack notify
# channel = "#test-canary-notifications"
# url = "https://hooks.slack.com/services/xx/yyy/zzzz"
# user = "Flagger"
# }
}
# metrics_and_alerts_configs = { # (optional) configure custom flagger metric template and alert providers
# # createNginxCustomMetricTemplates: true # false by default
# metricTemplates : {
# "my-custom-request-rate-metric-template" : {
# provider : { # (optional, defaults to metricTemplatesDefaultProvider)
# type : "prometheus"
# address : "http://flagger-prometheus.ingress-nginx:9090"
# }
# query : "sum(rate(nginx_ingress_controller_requests{namespace=\"{{ namespace }}\",ingress=\"{{ ingress }}\",status!~\"5.*\"}[1m]))/sum(rate(nginx_ingress_controller_requests{namespace=\"{{ namespace }\",ingress=\"{{ ingress }}\"}[1m]))*100"
# }
# }

# alertProviders : {
# on-call : { # The uniq name of channel
# type : "slack"
# channel : "test-canary-notifications-alert-provider" # The channel of notify/alerting (optional default to "general") # The channel of notify/alerting (optional default to "general")
# username : "flagger" # The sender name in notify/alert (optional default to "flagger")
# address : "https://hooks.slack.com/services/xx/yyy/zzzz"
# }
# }
# }
}
}

Expand All @@ -72,7 +98,7 @@ resource "helm_release" "http_echo" {
repository = "https://dasmeta.github.io/helm"
chart = "base"
namespace = "default"
version = "0.2.7"
version = "0.2.8"
wait = true

values = [file("${path.module}/http-echo-canary-eks.yaml")]
Expand Down
3 changes: 3 additions & 0 deletions examples/eks-with-flagger/http-echo-canary-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ image:
repository: mendhak/http-https-echo
tag: 34

config:
TEST_CONFIG_FOR_ROLLOUT_TRIGGER: "1"

containerPort: 8080

service:
Expand Down
2 changes: 1 addition & 1 deletion examples/external-dns-enabled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.41 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion examples/spot-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.41 |

## Modules

Expand Down
11 changes: 5 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,11 @@ module "external-dns" {
module "flagger" {
count = var.create && var.flagger.enabled ? 1 : 0

source = "./modules/flagger"
namespace = var.flagger.namespace
configs = var.flagger.configs
metric_template_configs = var.flagger.metric_template_configs
enable_metric_template = var.flagger.enable_metric_template
enable_loadtester = var.flagger.enable_loadtester
source = "./modules/flagger"
namespace = var.flagger.namespace
configs = var.flagger.configs
metrics_and_alerts_configs = var.flagger.metrics_and_alerts_configs
enable_loadtester = var.flagger.enable_loadtester

depends_on = [
module.eks-cluster
Expand Down
9 changes: 4 additions & 5 deletions modules/flagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ No modules.
| Name | Type |
|------|------|
| [helm_release.flagger_loadtester](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.flagger_metric_template](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.flagger_metrics_and_alerts](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.this](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |

## Inputs
Expand All @@ -48,12 +48,11 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_atomic"></a> [atomic](#input\_atomic) | Whether use helm deploy with --atomic flag | `bool` | `false` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | The app chart version | `string` | `"1.38.0"` | no |
| <a name="input_configs"></a> [configs](#input\_configs) | Configurations to pass and override default ones. Check the helm chart available configs here: https://artifacthub.io/packages/helm/flagger/flagger?modal=values | `any` | `{}` | no |
| <a name="input_configs"></a> [configs](#input\_configs) | Configurations to pass and override default flagger chart configs. Check the helm chart available configs here: https://artifacthub.io/packages/helm/flagger/flagger?modal=values | `any` | `{}` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create namespace if requested | `bool` | `true` | no |
| <a name="input_enable_loadtester"></a> [enable\_loadtester](#input\_enable\_loadtester) | Whether to install loadtester helm | `bool` | `false` | no |
| <a name="input_enable_metric_template"></a> [enable\_metric\_template](#input\_enable\_metric\_template) | Whether to install flagger-metric-template helm | `bool` | `false` | no |
| <a name="input_enable_loadtester"></a> [enable\_loadtester](#input\_enable\_loadtester) | Whether to install flagger loadtester helm | `bool` | `false` | no |
| <a name="input_metric_template_chart_version"></a> [metric\_template\_chart\_version](#input\_metric\_template\_chart\_version) | The metric template chart version | `string` | `"0.1.0"` | no |
| <a name="input_metric_template_configs"></a> [metric\_template\_configs](#input\_metric\_template\_configs) | Configurations to pass and override default ones. Check the helm chart available configs here: https://github.com/dasmeta/helm/tree/flagger-metric-template-0.1.0/charts/flagger-metric-template | `any` | `{}` | no |
| <a name="input_metrics_and_alerts_configs"></a> [metrics\_and\_alerts\_configs](#input\_metrics\_and\_alerts\_configs) | Configurations to pass and override default flagger-metrics-and-alerts chart configs. If empty no chart will be deployed. Check the helm chart available configs here: https://github.com/dasmeta/helm/tree/flagger-metrics-and-alerts-0.1.0/charts/flagger-metrics-and-alerts | `any` | `{}` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace to install main helm. | `string` | `"ingress-nginx"` | no |
| <a name="input_wait"></a> [wait](#input\_wait) | Whether use helm deploy with --wait flag | `bool` | `true` | no |

Expand Down
10 changes: 5 additions & 5 deletions modules/flagger/metric-template.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
resource "helm_release" "flagger_metric_template" {
count = var.enable_metric_template ? 1 : 0
resource "helm_release" "flagger_metrics_and_alerts" {
count = var.metrics_and_alerts_configs != {} ? 1 : 0

name = "flagger-metric-template"
name = "flagger-metrics-and-alerts"
repository = "https://dasmeta.github.io/helm"
chart = "flagger-metric-template"
chart = "flagger-metrics-and-alerts"
namespace = var.namespace
version = var.metric_template_chart_version
create_namespace = false
atomic = var.atomic
wait = var.wait

values = [jsonencode(var.metric_template_configs)]
values = [jsonencode(var.metrics_and_alerts_configs)]

depends_on = [helm_release.this]
}
14 changes: 4 additions & 10 deletions modules/flagger/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,17 @@ variable "wait" {
variable "configs" {
type = any
default = {}
description = "Configurations to pass and override default ones. Check the helm chart available configs here: https://artifacthub.io/packages/helm/flagger/flagger?modal=values"
description = "Configurations to pass and override default flagger chart configs. Check the helm chart available configs here: https://artifacthub.io/packages/helm/flagger/flagger?modal=values"
}

variable "enable_metric_template" {
type = bool
default = false
description = "Whether to install flagger-metric-template helm"
}

variable "metric_template_configs" {
variable "metrics_and_alerts_configs" {
type = any
default = {}
description = "Configurations to pass and override default ones. Check the helm chart available configs here: https://github.com/dasmeta/helm/tree/flagger-metric-template-0.1.0/charts/flagger-metric-template"
description = "Configurations to pass and override default flagger-metrics-and-alerts chart configs. If empty no chart will be deployed. Check the helm chart available configs here: https://github.com/dasmeta/helm/tree/flagger-metrics-and-alerts-0.1.0/charts/flagger-metrics-and-alerts"
}

variable "enable_loadtester" {
type = bool
default = false
description = "Whether to install loadtester helm"
description = "Whether to install flagger loadtester helm"
}
11 changes: 5 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,11 @@ variable "external_dns" {

variable "flagger" {
type = object({
enabled = optional(bool, false)
namespace = optional(string, "ingress-nginx") # The flagger operator helm being installed on same namespace as mesh/ingress provider so this field need to be set based on which ingress/mesh we are going to use, more info in https://artifacthub.io/packages/helm/flagger/flagger
configs = optional(any, {}) # available options can be found in https://artifacthub.io/packages/helm/flagger/flagger
metric_template_configs = optional(any, {}) # available options can be found in https://github.com/dasmeta/helm/tree/flagger-metric-template-0.1.0/charts/flagger-metric-template
enable_metric_template = optional(bool, false)
enable_loadtester = optional(bool, false)
enabled = optional(bool, false)
namespace = optional(string, "ingress-nginx") # The flagger operator helm being installed on same namespace as mesh/ingress provider so this field need to be set based on which ingress/mesh we are going to use, more info in https://artifacthub.io/packages/helm/flagger/flagger
configs = optional(any, {}) # Available options can be found in https://artifacthub.io/packages/helm/flagger/flagger
metrics_and_alerts_configs = optional(any, {}) # Available options can be found in https://github.com/dasmeta/helm/tree/flagger-metrics-and-alerts-0.1.0/charts/flagger-metrics-and-alerts
enable_loadtester = optional(bool, false) # Whether to install flagger loadtester helm
})
default = {
enabled = false
Expand Down

0 comments on commit 10f1343

Please sign in to comment.