From 5408b1cdd550acc55d17170df2e0ae3d06d248c2 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 4 Jun 2024 10:39:23 -0700 Subject: [PATCH] Run migrate job as pre hook with option to auto cleanup xref: https://x.com/tsaha/status/1805382111844778275 Signed-off-by: Tamal Saha --- charts/openfga/Chart.yaml | 2 +- charts/openfga/templates/job.yaml | 16 ++++++++++++---- charts/openfga/values.yaml | 13 +++++++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/charts/openfga/Chart.yaml b/charts/openfga/Chart.yaml index 80261e6..272b44d 100644 --- a/charts/openfga/Chart.yaml +++ b/charts/openfga/Chart.yaml @@ -3,7 +3,7 @@ name: openfga description: A Kubernetes Helm chart for the OpenFGA project. type: application -version: 0.2.6 +version: 0.2.7 appVersion: "v1.5.4" home: "https://openfga.github.io/helm-charts" diff --git a/charts/openfga/templates/job.yaml b/charts/openfga/templates/job.yaml index 8a1acdc..37768a7 100644 --- a/charts/openfga/templates/job.yaml +++ b/charts/openfga/templates/job.yaml @@ -8,11 +8,20 @@ metadata: {{- with .Values.migrate.labels }} {{- toYaml . | nindent 4}} {{- end}} - {{- with .Values.migrate.annotations }} annotations: - {{- toYaml . | nindent 4 }} - {{- end }} + {{- with .Values.migrate.annotations }} + {{- toYaml . | nindent 4}} + {{- end}} + {{- if .Values.migrate.hook.enable }} + helm.sh/hook: {{ .Values.migrate.hook.hook | quote }} + helm.sh/hook-weight: {{ .Values.migrate.hook.hookWeight | quote }} + helm.sh/hook-delete-policy: {{ .Values.migrate.hook.hookDeletePolicy | quote }} + {{- end}} spec: + backoffLimit: 3 + {{- if ge (int .Values.migrate.ttlSecondsAfterFinished) 0 }} + ttlSecondsAfterFinished: {{ .Values.migrate.ttlSecondsAfterFinished }} + {{- end }} template: metadata: {{- with .Values.migrate.annotations }} @@ -79,5 +88,4 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} - backoffLimit: 1 {{- end }} diff --git a/charts/openfga/values.yaml b/charts/openfga/values.yaml index 5222fe7..0c1b593 100644 --- a/charts/openfga/values.yaml +++ b/charts/openfga/values.yaml @@ -320,9 +320,14 @@ affinity: {} sidecars: [] migrate: sidecars: [] - annotations: - helm.sh/hook: "post-install, post-upgrade, post-rollback, post-delete" - helm.sh/hook-weight: "-5" - helm.sh/hook-delete-policy: "before-hook-creation" + # https://github.com/fluxcd/flux2/discussions/1085#discussioncomment-473271 + # https://github.com/helm/helm/issues/9027#issuecomment-1908032461 + hook: + enable: true + hook: "post-install, post-upgrade, post-rollback, post-delete" + hookWeight: "-5" + hookDeletePolicy: "before-hook-creation" + annotations: {} labels: {} timeout: + ttlSecondsAfterFinished: -1