Skip to content

Commit

Permalink
✨(grafana) add post deployment hooks support
Browse files Browse the repository at this point in the history
Some dashboards may require to be modified once deployed by injecting
grafana database values in their source.

Those hooks are scripts distributed along with compiled dashboards and
will be executed in a side-car container so that it can access to the
temporary volume used to provision dashboards. This requires
post-deployment hooks scripts to be idempotent.
  • Loading branch information
jmaupetit committed Apr 12, 2022
1 parent 63fd7fa commit e551eaa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/grafana/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions apps/grafana/templates/services/app/deploy.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
12 changes: 12 additions & 0 deletions apps/grafana/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -44,3 +51,8 @@ grafana_postgresql_resources:
requests:
cpu: 10m
memory: 100Mi

grafana_hooks_resources:
requests:
cpu: 10m
memory: 100Mi

0 comments on commit e551eaa

Please sign in to comment.