diff --git a/apps/grafana/CHANGELOG.md b/apps/grafana/CHANGELOG.md index 8c3a512..4838f46 100644 --- a/apps/grafana/CHANGELOG.md +++ b/apps/grafana/CHANGELOG.md @@ -8,6 +8,10 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ## [Unreleased] +### Added + +- Implement support for post-deployment hook scripts as sidecar containers + ## [1.0.0] - 2021-12-03 ### Added diff --git a/apps/grafana/templates/services/app/deploy.yml.j2 b/apps/grafana/templates/services/app/deploy.yml.j2 index a0bf576..88e96a6 100644 --- a/apps/grafana/templates/services/app/deploy.yml.j2 +++ b/apps/grafana/templates/services/app/deploy.yml.j2 @@ -93,6 +93,21 @@ spec: - name: grafana-provisioning-dashboards mountPath: /etc/grafana/provisioning/dashboards/dashboards.yml subPath: dashboards.yml +{% if grafana_activate_hooks %} + - name: hooks + image: "{{ grafana_hooks_image_name }}:{{ grafana_hooks_image_tag }}" + imagePullPolicy: Always + command: {{ grafana_hooks_commands }} + envFrom: + - secretRef: + name: "{{ grafana_secret_name }}" + - configMapRef: + name: "grafana-app-dotenv-{{ deployment_stamp }}" + resources: {{ grafana_hooks_resources }} + volumeMounts: + - mountPath: /var/lib/grafana + name: grafana-resources +{% endif %} securityContext: runAsUser: {{ grafana_container_uid }} runAsGroup: {{ grafana_container_gid }} diff --git a/apps/grafana/vars/all/main.yml b/apps/grafana/vars/all/main.yml index 02e26a5..25e72d5 100644 --- a/apps/grafana/vars/all/main.yml +++ b/apps/grafana/vars/all/main.yml @@ -33,6 +33,13 @@ grafana_dashboards_providers: [] # Datasources providers # https://grafana.com/docs/grafana/latest/administration/provisioning/#data-sources grafana_datasources_providers: [] +# Hooks +# If activated, hooks allow to modify provided dashboards or datasources +# (post deployment). +grafana_activate_hooks: false +grafana_hooks_image_name: "fundocker/curl-jq" +grafana_hooks_image_tag: latest +grafana_hooks_commands: [] # -- resources requests grafana_app_resources: @@ -44,3 +51,8 @@ grafana_postgresql_resources: requests: cpu: 10m memory: 100Mi + +grafana_hooks_resources: + requests: + cpu: 10m + memory: 100Mi