From 0357121d171e343c3b1bd9d90a3877d000e352a2 Mon Sep 17 00:00:00 2001 From: Andrew Hibbert <77166944+andrewhibbert@users.noreply.github.com> Date: Thu, 28 Jul 2022 04:51:16 +0100 Subject: [PATCH] Optionally run a command when completing jobs (#15017) --- .../templates/post-install-create-bucket-job.yaml | 5 +++++ .../templates/post-install-create-policy-job.yaml | 5 +++++ .../templates/post-install-create-user-job.yaml | 5 +++++ .../minio/templates/post-install-custom-command.yaml | 5 +++++ helm/minio/values.yaml | 12 ++++++++++-- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/helm/minio/templates/post-install-create-bucket-job.yaml b/helm/minio/templates/post-install-create-bucket-job.yaml index 434b31dd5..37d4f6bd9 100644 --- a/helm/minio/templates/post-install-create-bucket-job.yaml +++ b/helm/minio/templates/post-install-create-bucket-job.yaml @@ -69,7 +69,12 @@ spec: - name: minio-mc image: "{{ .Values.mcImage.repository }}:{{ .Values.mcImage.tag }}" imagePullPolicy: {{ .Values.mcImage.pullPolicy }} + {{- if .Values.makeBucketJob.exitCommand }} + command: ["/bin/sh", "-c"] + args: ["/bin/sh /config/initialize; x=$(echo $?); {{ .Values.makeBucketJob.exitCommand }} && exit $x" ] + {{- else }} command: ["/bin/sh", "/config/initialize"] + {{- end }} env: - name: MINIO_ENDPOINT value: {{ template "minio.fullname" . }} diff --git a/helm/minio/templates/post-install-create-policy-job.yaml b/helm/minio/templates/post-install-create-policy-job.yaml index ae787692d..cf3c6602a 100644 --- a/helm/minio/templates/post-install-create-policy-job.yaml +++ b/helm/minio/templates/post-install-create-policy-job.yaml @@ -69,7 +69,12 @@ spec: - name: minio-mc image: "{{ .Values.mcImage.repository }}:{{ .Values.mcImage.tag }}" imagePullPolicy: {{ .Values.mcImage.pullPolicy }} + {{- if .Values.makePolicyJob.exitCommand }} + command: ["/bin/sh", "-c"] + args: ["/bin/sh /config/add-policy; x=$(echo $?); {{ .Values.makePolicyJob.exitCommand }} && exit $x" ] + {{- else }} command: ["/bin/sh", "/config/add-policy"] + {{- end }} env: - name: MINIO_ENDPOINT value: {{ template "minio.fullname" . }} diff --git a/helm/minio/templates/post-install-create-user-job.yaml b/helm/minio/templates/post-install-create-user-job.yaml index d3750e8cb..aa8b5aaf8 100644 --- a/helm/minio/templates/post-install-create-user-job.yaml +++ b/helm/minio/templates/post-install-create-user-job.yaml @@ -79,7 +79,12 @@ spec: - name: minio-mc image: "{{ .Values.mcImage.repository }}:{{ .Values.mcImage.tag }}" imagePullPolicy: {{ .Values.mcImage.pullPolicy }} + {{- if .Values.makeUserJob.exitCommand }} + command: ["/bin/sh", "-c"] + args: ["/bin/sh /config/add-user; x=$(echo $?); {{ .Values.makeUserJob.exitCommand }} && exit $x" ] + {{- else }} command: ["/bin/sh", "/config/add-user"] + {{- end }} env: - name: MINIO_ENDPOINT value: {{ template "minio.fullname" . }} diff --git a/helm/minio/templates/post-install-custom-command.yaml b/helm/minio/templates/post-install-custom-command.yaml index 7e83faf60..48cbd7578 100644 --- a/helm/minio/templates/post-install-custom-command.yaml +++ b/helm/minio/templates/post-install-custom-command.yaml @@ -69,7 +69,12 @@ spec: - name: minio-mc image: "{{ .Values.mcImage.repository }}:{{ .Values.mcImage.tag }}" imagePullPolicy: {{ .Values.mcImage.pullPolicy }} + {{- if .Values.customCommandJob.exitCommand }} + command: ["/bin/sh", "-c"] + args: ["/bin/sh /config/custom-command; x=$(echo $?); {{ .Values.customCommandJob.exitCommand }} && exit $x" ] + {{- else }} command: ["/bin/sh", "/config/custom-command"] + {{- end }} env: - name: MINIO_ENDPOINT value: {{ template "minio.fullname" . }} diff --git a/helm/minio/values.yaml b/helm/minio/values.yaml index fa23381b5..3af1f2c95 100644 --- a/helm/minio/values.yaml +++ b/helm/minio/values.yaml @@ -310,6 +310,8 @@ makePolicyJob: nodeSelector: {} tolerations: [] affinity: {} + # Command to run after the main command on exit + exitCommand: "" ## List of users to be created after minio install ## @@ -344,6 +346,8 @@ makeUserJob: nodeSelector: {} tolerations: [] affinity: {} + # Command to run after the main command on exit + exitCommand: "" ## List of buckets to be created after minio install ## @@ -378,7 +382,9 @@ makeBucketJob: nodeSelector: {} tolerations: [] affinity: {} - + # Command to run after the main command on exit + exitCommand: "" + ## List of command to run after minio install ## NOTE: the mc command TARGET is always "myminio" customCommands: @@ -399,7 +405,9 @@ customCommandJob: nodeSelector: {} tolerations: [] affinity: {} - + # Command to run after the main command on exit + exitCommand: "" + ## Use this field to add environment variables relevant to MinIO server. These fields will be passed on to MinIO container(s) ## when Chart is deployed environment: