This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
/
job-update-patroni.yaml
48 lines (45 loc) · 1.96 KB
/
job-update-patroni.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
39
40
41
42
43
44
45
46
47
48
# This file and its contents are licensed under the Apache License 2.0.
# Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
{{/*
The sole purpose of this job is to trigger Patroni to rewrite the
Dynamic Configuration[1] in the DCS.
As the configuration may change between every invocation of Helm, we
need to run this trigger after every update.
To prevent Helm failing to update a deployment, we add helm release revision
number to the created job name; Helm cannot create a job with the same name,
however, (completed) jobs will not immediately be removed by Kubernetes.
1: https://patroni.readthedocs.io/en/latest/dynamic_configuration.html
*/}}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ template "timescaledb.fullname" . }}-patroni-{{ .Release.Revision }}"
namespace: {{ .Release.Namespace }}
labels:
{{ include "timescaledb-helm.labels" . | nindent 4 }}
app.kubernetes.io/component: patroni
annotations:
"helm.sh/hook": post-upgrade
"helm.sh/hook-delete-policy": hook-succeeded
spec:
activeDeadlineSeconds: 120
template:
metadata:
labels:
{{ include "timescaledb-helm.labels" . | nindent 8 }}
spec:
restartPolicy: OnFailure
containers:
- name: {{ template "timescaledb.fullname" . }}-patch-patroni-config
image: "{{ .Values.curlImage.repository }}:{{ .Values.curlImage.tag }}"
imagePullPolicy: {{ .Values.curlImage.pullPolicy }}
command: ["/bin/sh"]
# Patching the Patroni configuration is good, however it should not block an upgrade from going through
# Therefore we ensure we always exit with an exitcode 0, so that Helm is satisfied with this upgrade job
args:
- '-c'
- |
/usr/bin/curl --connect-timeout 30 --include --request PATCH --data \
{{ .Values.patroni.bootstrap.dcs | toJson | quote }} \
"http://{{ template "clusterName" . }}-config:8008/config"
exit 0