From 59b6969f15fb95404407b9c6235f422c222b8d00 Mon Sep 17 00:00:00 2001 From: Junior Dongo Date: Thu, 5 Dec 2024 14:27:44 +0100 Subject: [PATCH] create windows configmaps only if windows nodes exist --- monitoring/onpremise/fluent-bit/README.md | 4 ++-- monitoring/onpremise/fluent-bit/entrypoint-configmap.tf | 1 + .../onpremise/fluent-bit/envvars-configmap-windows.tf | 3 ++- .../onpremise/fluent-bit/fluent-bit-configmap-windows.tf | 1 + monitoring/onpremise/fluent-bit/main.tf | 6 +++--- monitoring/onpremise/fluent-bit/outputs.tf | 6 +++--- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/monitoring/onpremise/fluent-bit/README.md b/monitoring/onpremise/fluent-bit/README.md index 5f1ec1f32..a87aaab05 100644 --- a/monitoring/onpremise/fluent-bit/README.md +++ b/monitoring/onpremise/fluent-bit/README.md @@ -10,7 +10,7 @@ | Name | Version | |------|---------| -| [kubernetes](#provider\_kubernetes) | 2.34.0 | +| [kubernetes](#provider\_kubernetes) | >= 2.21.1 | ## Modules @@ -30,8 +30,8 @@ No modules. | [kubernetes_config_map.fluent_bit_envvars_config](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/config_map) | resource | | [kubernetes_config_map.fluent_bit_envvars_config_windows](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/config_map) | resource | | [kubernetes_daemonset.fluent_bit](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/daemonset) | resource | -| [kubernetes_secret.aws_auth_config](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource | | [kubernetes_daemonset.fluent_bit_windows](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/daemonset) | resource | +| [kubernetes_secret.aws_auth_config](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret) | resource | | [kubernetes_service_account.fluent_bit](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource | | [kubernetes_service_account.fluent_bit_windows](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource | diff --git a/monitoring/onpremise/fluent-bit/entrypoint-configmap.tf b/monitoring/onpremise/fluent-bit/entrypoint-configmap.tf index 4133c5bc1..e1a5b6bd6 100644 --- a/monitoring/onpremise/fluent-bit/entrypoint-configmap.tf +++ b/monitoring/onpremise/fluent-bit/entrypoint-configmap.tf @@ -1,4 +1,5 @@ resource "kubernetes_config_map" "fluent_bit_entrypoint" { + count = (length(var.node_selector_windows) > 0 ? 1 : 0) metadata { name = "fluent-bit-entrypoint" namespace = var.namespace diff --git a/monitoring/onpremise/fluent-bit/envvars-configmap-windows.tf b/monitoring/onpremise/fluent-bit/envvars-configmap-windows.tf index a5a5e81a3..7b76fbb53 100644 --- a/monitoring/onpremise/fluent-bit/envvars-configmap-windows.tf +++ b/monitoring/onpremise/fluent-bit/envvars-configmap-windows.tf @@ -1,5 +1,6 @@ # configmap with all the variables resource "kubernetes_config_map" "fluent_bit_envvars_config_windows" { + count = (length(var.node_selector_windows) > 0 ? 1 : 0) metadata { name = "fluent-bit-envvars-config-windows" namespace = var.namespace @@ -17,7 +18,7 @@ resource "kubernetes_config_map" "fluent_bit_envvars_config_windows" { APPLICATION_CLOUDWATCH_AUTO_CREATE_LOG_GROUP = (local.cloudwatch_name == "" && local.cloudwatch_enabled) AWS_S3_NAME = local.s3_name AWS_REGION_S3 = local.s3_region - PREFIX = local.s3_prefix + S3_KEY_FORMAT = local.s3_key_format PARSER = local.fluent_bit_windows_parser KUBE_CA_FILE = local.fluent_bit_kube_ca_file_windows KUBE_TOKEN_FILE = local.fluent_bit_kube_token_file_windows diff --git a/monitoring/onpremise/fluent-bit/fluent-bit-configmap-windows.tf b/monitoring/onpremise/fluent-bit/fluent-bit-configmap-windows.tf index 04309728d..027b685eb 100644 --- a/monitoring/onpremise/fluent-bit/fluent-bit-configmap-windows.tf +++ b/monitoring/onpremise/fluent-bit/fluent-bit-configmap-windows.tf @@ -1,5 +1,6 @@ # configmap with all the variables resource "kubernetes_config_map" "fluent_bit_config_windows" { + count = (length(var.node_selector_windows) > 0 ? 1 : 0) metadata { name = "fluent-bit-configmap-windows" namespace = var.namespace diff --git a/monitoring/onpremise/fluent-bit/main.tf b/monitoring/onpremise/fluent-bit/main.tf index 21e3534db..4a3f07d7a 100644 --- a/monitoring/onpremise/fluent-bit/main.tf +++ b/monitoring/onpremise/fluent-bit/main.tf @@ -221,7 +221,7 @@ resource "kubernetes_daemonset" "fluent_bit_windows" { } env_from { config_map_ref { - name = kubernetes_config_map.fluent_bit_envvars_config_windows.metadata[0].name + name = kubernetes_config_map.fluent_bit_envvars_config_windows[0].metadata[0].name } } volume_mount { @@ -260,13 +260,13 @@ resource "kubernetes_daemonset" "fluent_bit_windows" { volume { name = "fluent-bit-config" config_map { - name = kubernetes_config_map.fluent_bit_config_windows.metadata[0].name + name = kubernetes_config_map.fluent_bit_config_windows[0].metadata[0].name } } volume { name = "entrypoint-script" config_map { - name = kubernetes_config_map.fluent_bit_entrypoint.metadata[0].name + name = kubernetes_config_map.fluent_bit_entrypoint[0].metadata[0].name } } host_network = false diff --git a/monitoring/onpremise/fluent-bit/outputs.tf b/monitoring/onpremise/fluent-bit/outputs.tf index 7329a5c30..efbe17409 100644 --- a/monitoring/onpremise/fluent-bit/outputs.tf +++ b/monitoring/onpremise/fluent-bit/outputs.tf @@ -49,8 +49,8 @@ output "windows_is_daemonset" { output "windows_configmaps" { description = "Configmaps of Fluent-bit" value = { - envvars = kubernetes_config_map.fluent_bit_envvars_config_windows.metadata[0].name - config = kubernetes_config_map.fluent_bit_config_windows.metadata[0].name - entry = kubernetes_config_map.fluent_bit_entrypoint.metadata[0].name + envvars = kubernetes_config_map.fluent_bit_envvars_config_windows[0].metadata[0].name + config = kubernetes_config_map.fluent_bit_config_windows[0].metadata[0].name + entry = kubernetes_config_map.fluent_bit_entrypoint[0].metadata[0].name } }