From ccf1c532da4479ea2755bd382a8bbb93b33a8ed0 Mon Sep 17 00:00:00 2001 From: Juho Holmi Date: Mon, 3 May 2021 22:06:43 +0300 Subject: [PATCH] Use secret to provide Grafana dashboards --- modules/container_deployment/main.tf | 10 ++++++---- modules/container_deployment/prom_values.yaml | 18 ++++++++++++++++++ modules/container_deployment/variables.tf | 3 --- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/container_deployment/main.tf b/modules/container_deployment/main.tf index 993e30b..bf4fb54 100644 --- a/modules/container_deployment/main.tf +++ b/modules/container_deployment/main.tf @@ -40,7 +40,7 @@ resource "helm_release" "hono" { chart = "hono" version = "~> 1.5.9" cleanup_on_fail = "true" - depends_on = [helm_release.kube-prometheus-stack] + #depends_on = [helm_release.mongodb] values = [ file("${path.module}/hono_values.yaml") ] @@ -77,8 +77,10 @@ resource "helm_release" "jaeger-operator" { # Import Hono dashboards to Grafana. Basically copied from Hono Helm charts. # How to import dashboards: https://github.com/grafana/helm-charts/tree/3327b6c7e9417f345774fd5a5eb46dd639ebeeec/charts/grafana#import-dashboards -# This resource uses sidecar method: https://github.com/grafana/helm-charts/tree/3327b6c7e9417f345774fd5a5eb46dd639ebeeec/charts/grafana#sidecar-for-dashboards -resource "kubernetes_config_map" "grafana_hono_dashboards" { +# Sidecar method: https://github.com/grafana/helm-charts/tree/3327b6c7e9417f345774fd5a5eb46dd639ebeeec/charts/grafana#sidecar-for-dashboards +# This resource uses dashboard provisioning: https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards +# https://www.gitmemory.com/issue/helm/charts/16006/521211747 +resource "kubernetes_secret" "grafana_hono_dashboards" { metadata { name = "grafana-hono-dashboards" labels = { @@ -101,7 +103,7 @@ resource "helm_release" "kube-prometheus-stack" { repository = "https://prometheus-community.github.io/helm-charts" chart = "kube-prometheus-stack" version = "~> 14.5.0" - depends_on = [helm_release.mongodb, kubernetes_config_map.grafana_hono_dashboards] + depends_on = [kubernetes_secret.grafana_hono_dashboards] cleanup_on_fail = "true" values = [ file("${path.module}/prom_values.yaml") diff --git a/modules/container_deployment/prom_values.yaml b/modules/container_deployment/prom_values.yaml index def6ec6..9043a81 100644 --- a/modules/container_deployment/prom_values.yaml +++ b/modules/container_deployment/prom_values.yaml @@ -1,6 +1,24 @@ grafana: + dashboardProviders: + dashboardproviders.yaml: + apiVersion: 1 + providers: + - name: 'Hono' + orgId: 1 + folder: 'Hono' + type: file + disableDeletion: true + editable: false + options: + path: /etc/secrets/dashboards/ service: type: "LoadBalancer" + extraSecretMounts: + - name: dashboards-secret-mount + secretName: grafana-hono-dashboards + defaultMode: 0440 + mountPath: /etc/secrets/dashboards + readOnly: true prometheusOperator: service: type: "LoadBalancer" diff --git a/modules/container_deployment/variables.tf b/modules/container_deployment/variables.tf index 180f837..40c00dc 100644 --- a/modules/container_deployment/variables.tf +++ b/modules/container_deployment/variables.tf @@ -18,7 +18,4 @@ variable "mongodb_rootPassword" { default = "root-secret" type = string description = "Optional password for MongoDB" - } - -