From 83cbf398220a123f9614e11e6c9df6ad9b333358 Mon Sep 17 00:00:00 2001 From: Junior Dongo Date: Mon, 28 Oct 2024 09:46:02 +0100 Subject: [PATCH 1/2] feat: add windows node exporter --- infrastructure/quick-deploy/aws/ecr.tf | 1 + infrastructure/quick-deploy/aws/monitoring.tf | 14 ++++++++++++++ infrastructure/quick-deploy/aws/parameters.tfvars | 7 +++++++ infrastructure/quick-deploy/aws/variables.tf | 10 ++++++++++ versions.tfvars.json | 3 ++- 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/infrastructure/quick-deploy/aws/ecr.tf b/infrastructure/quick-deploy/aws/ecr.tf index dd847792b..f6c7fcc9f 100644 --- a/infrastructure/quick-deploy/aws/ecr.tf +++ b/infrastructure/quick-deploy/aws/ecr.tf @@ -20,6 +20,7 @@ locals { var.seq == null ? null : [var.seq.cli_image_name, var.seq.cli_image_tag], var.grafana == null ? null : [var.grafana.image_name, var.grafana.image_tag], var.node_exporter == null ? null : [var.node_exporter.image_name, var.node_exporter.image_tag], + var.windows_exporter == null ? null : [var.windows_exporter.image_name, var.windows_exporter.image_tag], var.partition_metrics_exporter == null ? null : [var.partition_metrics_exporter.image_name, var.partition_metrics_exporter.image_tag], var.ingress == null ? null : [var.ingress.image, var.ingress.tag], var.authentication == null ? null : [var.authentication.image, var.authentication.tag], diff --git a/infrastructure/quick-deploy/aws/monitoring.tf b/infrastructure/quick-deploy/aws/monitoring.tf index a29bc6263..d024eecc5 100644 --- a/infrastructure/quick-deploy/aws/monitoring.tf +++ b/infrastructure/quick-deploy/aws/monitoring.tf @@ -115,6 +115,20 @@ module "node_exporter" { } } +# windows exporter +module "windows_exporter" { + count = var.windows_exporter != null ? 1 : 0 + source = "./generated/infra-modules/monitoring/onpremise/exporters/windows-exporter" + namespace = local.namespace + node_selector = var.windows_exporter.node_selector + docker_image = { + image = local.ecr_images["${var.windows_exporter.image_name}:${try(coalesce(var.windows_exporter.image_tag), "")}"].image + tag = local.ecr_images["${var.windows_exporter.image_name}:${try(coalesce(var.windows_exporter.image_tag), "")}"].tag + image_pull_secrets = var.windows_exporter.pull_secrets + } + kubeconfig_file = module.eks.kubeconfig_file +} + # Metrics exporter module "metrics_exporter" { source = "./generated/infra-modules/monitoring/onpremise/exporters/metrics-exporter" diff --git a/infrastructure/quick-deploy/aws/parameters.tfvars b/infrastructure/quick-deploy/aws/parameters.tfvars index 674e44bfb..5a7ad2138 100644 --- a/infrastructure/quick-deploy/aws/parameters.tfvars +++ b/infrastructure/quick-deploy/aws/parameters.tfvars @@ -359,6 +359,13 @@ node_exporter = { node_selector = {} } +windows_exporter = { + node_selector = { + "service" = "windows" + } + # image_tag = "0.29.2-ltsc2022" +} + prometheus = { node_selector = { service = "metrics" } #persistent_volume = { diff --git a/infrastructure/quick-deploy/aws/variables.tf b/infrastructure/quick-deploy/aws/variables.tf index e8cbe81e5..5f52031b5 100644 --- a/infrastructure/quick-deploy/aws/variables.tf +++ b/infrastructure/quick-deploy/aws/variables.tf @@ -823,3 +823,13 @@ variable "static" { default = {} } +variable "windows_exporter" { + description = "Windows exporter configuration" + type = object({ + image_name = optional(string, "ghcr.io/prometheus-community/windows-exporter") + image_tag = optional(string) + pull_secrets = optional(string, "") + node_selector = optional(any, {}) + }) + default = null +} diff --git a/versions.tfvars.json b/versions.tfvars.json index efe1a6ee1..d6b4dfc1d 100644 --- a/versions.tfvars.json +++ b/versions.tfvars.json @@ -73,7 +73,8 @@ "bitnami/rabbitmq": "3.12.14", "ghcr.io/chaos-mesh/chaos-mesh": "v2.6.3", "ghcr.io/chaos-mesh/chaos-daemon": "v2.6.3", - "ghcr.io/chaos-mesh/chaos-dashboard": "v2.6.3" + "ghcr.io/chaos-mesh/chaos-dashboard": "v2.6.3", + "ghcr.io/prometheus-community/windows-exporter": "0.29.2-ltsc2022" }, "helm_charts" : { "keda" : { "repository" : "https://kedacore.github.io/charts" , "version" : "2.9.3"}, From c405527ef5ade50ff708affa2d60283c729d32de Mon Sep 17 00:00:00 2001 From: Junior Dongo Date: Mon, 4 Nov 2024 17:31:21 +0100 Subject: [PATCH 2/2] update adding variables and using kubectl provider --- infrastructure/quick-deploy/aws/ecr.tf | 1 + infrastructure/quick-deploy/aws/monitoring.tf | 6 +++++- infrastructure/quick-deploy/aws/parameters.tfvars | 3 +-- infrastructure/quick-deploy/aws/providers.tf | 12 ++++++++++++ infrastructure/quick-deploy/aws/variables.tf | 11 +++++++---- versions.tfvars.json | 5 +++-- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/infrastructure/quick-deploy/aws/ecr.tf b/infrastructure/quick-deploy/aws/ecr.tf index f6c7fcc9f..b565d39c1 100644 --- a/infrastructure/quick-deploy/aws/ecr.tf +++ b/infrastructure/quick-deploy/aws/ecr.tf @@ -21,6 +21,7 @@ locals { var.grafana == null ? null : [var.grafana.image_name, var.grafana.image_tag], var.node_exporter == null ? null : [var.node_exporter.image_name, var.node_exporter.image_tag], var.windows_exporter == null ? null : [var.windows_exporter.image_name, var.windows_exporter.image_tag], + var.windows_exporter == null ? null : [var.windows_exporter.init_image_name, var.windows_exporter.init_image_tag], var.partition_metrics_exporter == null ? null : [var.partition_metrics_exporter.image_name, var.partition_metrics_exporter.image_tag], var.ingress == null ? null : [var.ingress.image, var.ingress.tag], var.authentication == null ? null : [var.authentication.image, var.authentication.tag], diff --git a/infrastructure/quick-deploy/aws/monitoring.tf b/infrastructure/quick-deploy/aws/monitoring.tf index d024eecc5..33adc7994 100644 --- a/infrastructure/quick-deploy/aws/monitoring.tf +++ b/infrastructure/quick-deploy/aws/monitoring.tf @@ -126,7 +126,11 @@ module "windows_exporter" { tag = local.ecr_images["${var.windows_exporter.image_name}:${try(coalesce(var.windows_exporter.image_tag), "")}"].tag image_pull_secrets = var.windows_exporter.pull_secrets } - kubeconfig_file = module.eks.kubeconfig_file + init_docker_image = { + image = local.ecr_images["${var.windows_exporter.init_image_name}:${try(coalesce(var.windows_exporter.init_image_tag), "")}"].image + tag = local.ecr_images["${var.windows_exporter.init_image_name}:${try(coalesce(var.windows_exporter.init_image_tag), "")}"].tag + image_pull_secrets = var.windows_exporter.init_pull_secrets + } } # Metrics exporter diff --git a/infrastructure/quick-deploy/aws/parameters.tfvars b/infrastructure/quick-deploy/aws/parameters.tfvars index 5a7ad2138..7287c2985 100644 --- a/infrastructure/quick-deploy/aws/parameters.tfvars +++ b/infrastructure/quick-deploy/aws/parameters.tfvars @@ -361,9 +361,8 @@ node_exporter = { windows_exporter = { node_selector = { - "service" = "windows" + "plateform" = "windows" } - # image_tag = "0.29.2-ltsc2022" } prometheus = { diff --git a/infrastructure/quick-deploy/aws/providers.tf b/infrastructure/quick-deploy/aws/providers.tf index 8bff8e832..ee1b579f4 100644 --- a/infrastructure/quick-deploy/aws/providers.tf +++ b/infrastructure/quick-deploy/aws/providers.tf @@ -3,6 +3,18 @@ provider "aws" { profile = var.profile } +provider "kubectl" { + host = module.eks.cluster_endpoint + cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) + + exec { + api_version = "client.authentication.k8s.io/v1beta1" + command = "aws" + # This requires the awscli to be installed locally where Terraform is executed + args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--profile", var.profile] + } +} + provider "kubernetes" { host = module.eks.cluster_endpoint cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data) diff --git a/infrastructure/quick-deploy/aws/variables.tf b/infrastructure/quick-deploy/aws/variables.tf index 5f52031b5..7892ea469 100644 --- a/infrastructure/quick-deploy/aws/variables.tf +++ b/infrastructure/quick-deploy/aws/variables.tf @@ -826,10 +826,13 @@ variable "static" { variable "windows_exporter" { description = "Windows exporter configuration" type = object({ - image_name = optional(string, "ghcr.io/prometheus-community/windows-exporter") - image_tag = optional(string) - pull_secrets = optional(string, "") - node_selector = optional(any, {}) + image_name = optional(string, "ghcr.io/prometheus-community/windows-exporter") + image_tag = optional(string) + pull_secrets = optional(string, "") + init_image_name = optional(string, "mcr.microsoft.com/windows/nanoserver") + init_image_tag = optional(string) + init_pull_secrets = optional(string, "") + node_selector = optional(any, {}) }) default = null } diff --git a/versions.tfvars.json b/versions.tfvars.json index d6b4dfc1d..69b68c941 100644 --- a/versions.tfvars.json +++ b/versions.tfvars.json @@ -1,7 +1,7 @@ { "armonik_versions": { "armonik": "2.20.0", - "infra": "0.5.0-pre-8-f5b8bd3", + "infra": "0.5.1-pre-1-84546ad", "infra_plugins": "0.1.1", "core": "0.24.3", "api": "3.19.0", @@ -74,7 +74,8 @@ "ghcr.io/chaos-mesh/chaos-mesh": "v2.6.3", "ghcr.io/chaos-mesh/chaos-daemon": "v2.6.3", "ghcr.io/chaos-mesh/chaos-dashboard": "v2.6.3", - "ghcr.io/prometheus-community/windows-exporter": "0.29.2-ltsc2022" + "ghcr.io/prometheus-community/windows-exporter": "0.29.2-ltsc2022", + "mcr.microsoft.com/windows/nanoserver": "ltsc2022" }, "helm_charts" : { "keda" : { "repository" : "https://kedacore.github.io/charts" , "version" : "2.9.3"},