-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththanos-rule-patch.yaml
38 lines (38 loc) · 1.27 KB
/
thanos-rule-patch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
apiVersion: apps/v1
kind: Deployment
metadata:
name: thanos-rule
spec:
template:
spec:
# Patches $ENVIRONMENT and $PROVIDER inside alerts templates and places
# them into an emptyDir: {} for thanos-rule to read
initContainers:
- name: render-alerts
image: alpine
args:
- /bin/sh
- -c
- |
apk add --no-cache gettext;
for file in $(find /var/thanos/rule-templates/ -type f); do
f=$(basename $file);
# If the file has a .tmpl or .tpl extension - remove it
f=${f%".tmpl"} && f=${f%".tpl"}
envsubst '${ENVIRONMENT},${PROVIDER},${NODE_ROLL_WINDOW}' < $file > /var/thanos/rules/$f;
done;
volumeMounts:
- name: rules-rendered
mountPath: /var/thanos/rules
containers:
- name: thanos-rule
volumeMounts:
- name: rules-rendered
mountPath: /var/thanos/rules
volumes:
# $patch: replace doesn't seem to work here, so dropping the upstream
# rules volume completely and using a new one for rendered alerts.
- $patch: delete
name: rules
- name: rules-rendered
emptyDir: {}