Skip to content

Commit

Permalink
Use secret to provide Grafana dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
JouHouFin committed May 4, 2021
1 parent b9bb861 commit ccf1c53
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
10 changes: 6 additions & 4 deletions modules/container_deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
Expand Down Expand Up @@ -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 = {
Expand All @@ -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")
Expand Down
18 changes: 18 additions & 0 deletions modules/container_deployment/prom_values.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 0 additions & 3 deletions modules/container_deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ variable "mongodb_rootPassword" {
default = "root-secret"
type = string
description = "Optional password for MongoDB"

}


0 comments on commit ccf1c53

Please sign in to comment.