From c6d018583c17fb8206d49c00fac782d3907de399 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 6 Aug 2024 21:58:20 -0400 Subject: [PATCH] ns changes for testing --- README.md | 9 +++++---- main.tf | 17 +++-------------- variables.tf | 14 +++++++------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 158e5e9..a47a7de 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,9 @@ This modules uses Helm to deploy Prometheus to a cluster using the official char Versions are module variables, but latest versions are intended to be be reflected in the default values. + + + ## Requirements @@ -38,7 +41,6 @@ Versions are module variables, but latest versions are intended to be be reflect |------|------| | [helm_release.prometheus](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [kubernetes_namespace.ns](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource | -| [kubernetes_namespace.existing_ns](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/namespace) | data source | ## Inputs @@ -46,13 +48,12 @@ Versions are module variables, but latest versions are intended to be be reflect |------|-------------|------|---------|:--------:| | [alertmanager\_tag](#input\_alertmanager\_tag) | The image tag of the alertmanager image. | `string` | `"v0.27.0"` | no | | [cluster\_name](#input\_cluster\_name) | The name of the cluster into which prometheus will be installed. | `string` | n/a | yes | -| [create\_namespace](#input\_create\_namespace) | Indicates whether the `namespace` needs to be created ('true') or already exists (not `true`) | `bool` | `true` | no | | [kube\_state\_metrics\_tag](#input\_kube\_state\_metrics\_tag) | The image tag of the kube-state-metrics image. | `string` | `"v2.13.0"` | no | | [namespace](#input\_namespace) | The namespace to install the prometheus components. Defaults to 'prometheus' | `string` | `"prometheus"` | no | | [node\_exporter\_tag](#input\_node\_exporter\_tag) | The image tag of the node-exporter image. | `string` | `"v1.8.2"` | no | | [profile](#input\_profile) | AWS\_PROFILE to use to apply the terraform script. | `string` | `""` | no | -| [prometheus\_chart\_version](#input\_prometheus\_chart\_version) | The version of prometheus to install into the cluster. | `string` | `"25.24.1"` | no | -| [prometheus\_config\_reloader\_tag](#input\_prometheus\_config\_reloader\_tag) | The image tag of the prometheus-config-reloader image. | `string` | `"v0.74.0"` | no | +| [prometheus\_chart\_version](#input\_prometheus\_chart\_version) | The version of prometheus to install into the cluster. | `string` | `"25.25.0"` | no | +| [prometheus\_config\_reloader\_tag](#input\_prometheus\_config\_reloader\_tag) | The image tag of the prometheus-config-reloader image. | `string` | `"v0.75.2"` | no | | [prometheus\_server\_tag](#input\_prometheus\_server\_tag) | The image tag of prometheus server to install into the cluster. | `string` | `"v2.53.1"` | no | | [pushgateway\_tag](#input\_pushgateway\_tag) | The image tag of the pushgateway image. | `string` | `"v1.9.0"` | no | | [rwo\_storage\_class](#input\_rwo\_storage\_class) | Specify the storage class for read/write/once persistent volumes. | `string` | `"gp3-encrypted"` | no | diff --git a/main.tf b/main.tf index 9a93623..6f63a0e 100644 --- a/main.tf +++ b/main.tf @@ -8,6 +8,8 @@ locals { headless_alertmanager_internal_port_number = 9093 headless_alertmanager_internal_url = format("http://%v:%v/", local.alertmanager_internal_hostname, local.alertmanager_internal_port_number) + # ns = try(kubernetes_namespace.ns[0].metadata[0].name, data.kubernetes_namespace.existing_ns[0].metadata[0].name) + pushgateway_internal_hostname = format("prometheus-prometheus-pushgateway.%v.svc.cluster.local", local.ns) pushgateway_internal_port_number = 9091 pushgateway_internal_url = format("http://%v:%v/", local.pushgateway_internal_hostname, local.pushgateway_internal_port_number) @@ -18,8 +20,6 @@ locals { } resource "kubernetes_namespace" "ns" { - count = var.create_namespace == true ? 1 : 0 - metadata { name = var.namespace labels = { @@ -28,17 +28,6 @@ resource "kubernetes_namespace" "ns" { } } -data "kubernetes_namespace" "existing_ns" { - count = var.create_namespace == true ? 0 : 1 - - metadata { - name = var.namespace - } -} - -locals { - ns = try(kubernetes_namespace.ns[0].metadata[0].name, data.kubernetes_namespace.existing_ns[0].metadata[0].name) -} resource "helm_release" "prometheus" { depends_on = [ @@ -46,7 +35,7 @@ resource "helm_release" "prometheus" { ] chart = "prometheus" name = "prometheus" - namespace = local.ns + namespace = kubernetes_namespace.ns[0].metadata[0].name version = var.prometheus_chart_version repository = "https://prometheus-community.github.io/helm-charts" diff --git a/variables.tf b/variables.tf index 37bba80..483b268 100644 --- a/variables.tf +++ b/variables.tf @@ -15,18 +15,18 @@ variable "namespace" { default = "prometheus" } -variable "create_namespace" { - description = "Indicates whether the `namespace` needs to be created ('true') or already exists (not `true`)" - type = bool - default = true -} +# variable "create_namespace" { +# description = "Indicates whether the `namespace` needs to be created ('true') or already exists (not `true`)" +# type = bool +# default = true +# } # helm repo add prometheus-community https://prometheus-community.github.io/helm-charts # helm search repo prometheus-community/prometheus | head -2 variable "prometheus_chart_version" { description = "The version of prometheus to install into the cluster." type = string - default = "25.24.1" + default = "25.25.0" } # The `APP VERSION` of the output found while determining the chart version @@ -40,7 +40,7 @@ variable "prometheus_server_tag" { variable "prometheus_config_reloader_tag" { description = "The image tag of the prometheus-config-reloader image." type = string - default = "v0.75.1" + default = "v0.75.2" } # The `APP VERSION` of the output: