locals { prometheus_helm_repo = "https://charts.bitnami.com/bitnami" prometheus_helm_chart = "kube-prometheus" prometheus_helm_version = null // just use latest prometheus_release_name = "prometheus" prometheus_namespace = "prometheus" prometheus_remote_write_enabled = var.prometheus_remote_write_password != "" } # Create a namespace to hold our Prometheus deployment. resource "kubernetes_namespace" "prometheus_namespace" { metadata { name = local.prometheus_namespace } depends_on = [ google_container_node_pool.misc ] } # Create a secret to store the remote write key resource "kubernetes_secret" "prometheus-credentials" { count = local.prometheus_remote_write_enabled ? 1 : 0 type = "kubernetes.io/basic-auth" metadata { name = "prometheus-credentials" namespace = kubernetes_namespace.prometheus_namespace.metadata.0.name } data = { username = var.prometheus_remote_write_user password = var.prometheus_remote_write_password } } # Install Prometheus using the Bitnami Prometheus helm chart. resource "helm_release" "prometheus-chart" { repository = local.prometheus_helm_repo chart = local.prometheus_helm_chart name = local.prometheus_release_name version = local.prometheus_helm_version namespace = kubernetes_namespace.prometheus_namespace.metadata.0.name values = [<