Skip to content

Commit a570549

Browse files
committed
Run migrate job as pre hook with option to auto cleanup
xref: https://x.com/tsaha/status/1805382111844778275 Signed-off-by: Tamal Saha <[email protected]>
1 parent eed5562 commit a570549

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

charts/openfga/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: openfga
33
description: A Kubernetes Helm chart for the OpenFGA project.
44

55
type: application
6-
version: 0.2.6
6+
version: 0.2.7
77
appVersion: "v1.5.4"
88

99
home: "https://openfga.github.io/helm-charts"

charts/openfga/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
selector:
1616
matchLabels:
1717
{{- include "openfga.selectorLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: server
1819
template:
1920
metadata:
2021
annotations:
@@ -26,6 +27,7 @@ spec:
2627
prometheus.io/port: "{{ (split ":" .Values.telemetry.metrics.addr)._1 }}"
2728
labels:
2829
{{- include "openfga.selectorLabels" . | nindent 8 }}
30+
app.kubernetes.io/component: server
2931
spec:
3032
{{- with .Values.imagePullSecrets }}
3133
imagePullSecrets:

charts/openfga/templates/job.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,32 @@ metadata:
88
{{- with .Values.migrate.labels }}
99
{{- toYaml . | nindent 4}}
1010
{{- end}}
11-
{{- with .Values.migrate.annotations }}
1211
annotations:
13-
{{- toYaml . | nindent 4 }}
14-
{{- end }}
12+
{{- with .Values.migrate.annotations }}
13+
{{- toYaml . | nindent 4}}
14+
{{- end}}
15+
{{- if .Values.migrate.hook.enable }}
16+
helm.sh/hook: {{ .Values.migrate.hook.hook | quote }}
17+
helm.sh/hook-weight: {{ .Values.migrate.hook.hookWeight | quote }}
18+
helm.sh/hook-delete-policy: {{ .Values.migrate.hook.hookDeletePolicy | quote }}
19+
{{- end}}
1520
spec:
21+
backoffLimit: 3
22+
manualSelector: true
23+
selector:
24+
matchLabels:
25+
{{- include "openfga.selectorLabels" . | nindent 6 }}
26+
app.kubernetes.io/component: migrate
1627
template:
1728
metadata:
1829
{{- with .Values.migrate.annotations }}
1930
annotations:
2031
{{- toYaml . | nindent 8 }}
2132
{{- end }}
22-
{{- with .Values.migrate.labels }}
2333
labels:
34+
{{- include "openfga.selectorLabels" . | nindent 8 }}
35+
app.kubernetes.io/component: migrate
36+
{{- with .Values.migrate.labels }}
2437
{{- toYaml . | nindent 8 }}
2538
{{- end }}
2639
spec:
@@ -79,5 +92,4 @@ spec:
7992
tolerations:
8093
{{- toYaml . | nindent 8 }}
8194
{{- end }}
82-
backoffLimit: 1
8395
{{- end }}

charts/openfga/values.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,13 @@ affinity: {}
320320
sidecars: []
321321
migrate:
322322
sidecars: []
323-
annotations:
324-
helm.sh/hook: "post-install, post-upgrade, post-rollback, post-delete"
325-
helm.sh/hook-weight: "-5"
326-
helm.sh/hook-delete-policy: "before-hook-creation"
323+
# https://github.com/fluxcd/flux2/discussions/1085#discussioncomment-473271
324+
# https://github.com/helm/helm/issues/9027#issuecomment-1908032461
325+
hook:
326+
enable: false
327+
hook: "post-install, post-upgrade, post-rollback, post-delete"
328+
hookWeight: "-5"
329+
hookDeletePolicy: "before-hook-creation"
330+
annotations: {}
327331
labels: {}
328-
timeout:
332+
timeout: 10m

0 commit comments

Comments
 (0)