Skip to content

Commit ded76bc

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 88eaf10 commit ded76bc

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

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:
@@ -87,5 +100,4 @@ spec:
87100
tolerations:
88101
{{- toYaml . | nindent 8 }}
89102
{{- end }}
90-
backoffLimit: 1
91103
{{- end }}

charts/openfga/values.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,17 @@ migrate:
322322
extraVolumes: []
323323
extraVolumeMounts: []
324324
sidecars: []
325-
annotations:
326-
helm.sh/hook: "post-install, post-upgrade, post-rollback, post-delete"
327-
helm.sh/hook-weight: "-5"
328-
helm.sh/hook-delete-policy: "before-hook-creation"
325+
# https://github.com/fluxcd/flux2/discussions/1085#discussioncomment-473271
326+
# https://github.com/helm/helm/issues/9027#issuecomment-1908032461
327+
hook:
328+
enable: false
329+
hook: "post-install, post-upgrade, post-rollback, post-delete"
330+
hookWeight: "-5"
331+
hookDeletePolicy: "before-hook-creation"
332+
annotations: {}
329333
labels: {}
330-
timeout:
334+
timeout: 10m
335+
ttlSecondsAfterFinished: -1
331336

332337
# -- Array of extra K8s manifests to deploy
333338
## Note: Supports use of custom Helm templates

0 commit comments

Comments
 (0)