Skip to content

Commit 46de839

Browse files
committed
feat(charts): add grafana migration init container
1 parent 83409db commit 46de839

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

charts/grafana/templates/grafana-statefulset.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,39 @@ spec:
3737
- -u
3838
- $(GF_DATABASE_URL),http://drycc-controller-api
3939
{{- include "grafana.envs" . | indent 8 }}
40+
- name: drycc-grafana-migrate
41+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/grafana:{{.Values.imageTag}}
42+
imagePullPolicy: {{.Values.imagePullPolicy}}
43+
args:
44+
- /usr/bin/env
45+
- bash
46+
- -ec
47+
- |
48+
set -m
49+
echo "Configure Grafana live HA engine"
50+
DRYCC_VALKEY_JSON=$(echo "$DRYCC_VALKEY_URL" | jq -R 'capture("^(?<scheme>redis[s]?)://(?<username>[^:]+)?(?::(?<password>[^@]+))?@(?<address>[^/]+)/?(?<db>[0-9]*)$")')
51+
GF_LIVE_HA_ENGINE_ADDRESS=$(echo "${DRYCC_VALKEY_JSON}" |jq -r '.address')
52+
GF_LIVE_HA_ENGINE_PASSWORD=$(echo "${DRYCC_VALKEY_JSON}" |jq -r '.password')
53+
export GF_LIVE_HA_ENGINE_ADDRESS GF_LIVE_HA_ENGINE_PASSWORD
54+
grafana server --config /usr/share/grafana/grafana.ini --homepath /opt/drycc/grafana &
55+
GRAFANA_PID=$!
56+
echo "Waiting for Grafana to come up..."
57+
until curl -q --fail --output /dev/null --silent "http://localhost:3000/api/health"; do
58+
printf "."
59+
sleep 2
60+
done
61+
kill $GRAFANA_PID 2>/dev/null
62+
wait $GRAFANA_PID 2>/dev/null
63+
{{- include "grafana.envs" . | indent 8 }}
64+
volumeMounts:
65+
{{- if .Values.persistence.enabled }}
66+
- name: grafana-data
67+
mountPath: /var/lib/grafana
68+
{{- end }}
69+
- name: grafana-config
70+
subPath: grafana.ini
71+
readOnly: true
72+
mountPath: /usr/share/grafana/grafana.ini
4073
containers:
4174
- name: drycc-grafana
4275
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/grafana:{{.Values.imageTag}}

0 commit comments

Comments
 (0)