Skip to content

Commit

Permalink
ns changes for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Aug 21, 2024
1 parent 657969f commit c6d0185
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.




<!-- BEGIN_TF_DOCS -->
## Requirements

Expand Down Expand Up @@ -38,21 +41,19 @@ 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

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_alertmanager_tag"></a> [alertmanager\_tag](#input\_alertmanager\_tag) | The image tag of the alertmanager image. | `string` | `"v0.27.0"` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the cluster into which prometheus will be installed. | `string` | n/a | yes |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Indicates whether the `namespace` needs to be created ('true') or already exists (not `true`) | `bool` | `true` | no |
| <a name="input_kube_state_metrics_tag"></a> [kube\_state\_metrics\_tag](#input\_kube\_state\_metrics\_tag) | The image tag of the kube-state-metrics image. | `string` | `"v2.13.0"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace to install the prometheus components. Defaults to 'prometheus' | `string` | `"prometheus"` | no |
| <a name="input_node_exporter_tag"></a> [node\_exporter\_tag](#input\_node\_exporter\_tag) | The image tag of the node-exporter image. | `string` | `"v1.8.2"` | no |
| <a name="input_profile"></a> [profile](#input\_profile) | AWS\_PROFILE to use to apply the terraform script. | `string` | `""` | no |
| <a name="input_prometheus_chart_version"></a> [prometheus\_chart\_version](#input\_prometheus\_chart\_version) | The version of prometheus to install into the cluster. | `string` | `"25.24.1"` | no |
| <a name="input_prometheus_config_reloader_tag"></a> [prometheus\_config\_reloader\_tag](#input\_prometheus\_config\_reloader\_tag) | The image tag of the prometheus-config-reloader image. | `string` | `"v0.74.0"` | no |
| <a name="input_prometheus_chart_version"></a> [prometheus\_chart\_version](#input\_prometheus\_chart\_version) | The version of prometheus to install into the cluster. | `string` | `"25.25.0"` | no |
| <a name="input_prometheus_config_reloader_tag"></a> [prometheus\_config\_reloader\_tag](#input\_prometheus\_config\_reloader\_tag) | The image tag of the prometheus-config-reloader image. | `string` | `"v0.75.2"` | no |
| <a name="input_prometheus_server_tag"></a> [prometheus\_server\_tag](#input\_prometheus\_server\_tag) | The image tag of prometheus server to install into the cluster. | `string` | `"v2.53.1"` | no |
| <a name="input_pushgateway_tag"></a> [pushgateway\_tag](#input\_pushgateway\_tag) | The image tag of the pushgateway image. | `string` | `"v1.9.0"` | no |
| <a name="input_rwo_storage_class"></a> [rwo\_storage\_class](#input\_rwo\_storage\_class) | Specify the storage class for read/write/once persistent volumes. | `string` | `"gp3-encrypted"` | no |
Expand Down
17 changes: 3 additions & 14 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -18,8 +20,6 @@ locals {
}

resource "kubernetes_namespace" "ns" {
count = var.create_namespace == true ? 1 : 0

metadata {
name = var.namespace
labels = {
Expand All @@ -28,25 +28,14 @@ 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 = [
module.images,
]
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"

Expand Down
14 changes: 7 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit c6d0185

Please sign in to comment.