diff --git a/charts/ix-chart/2009.0.1/questions.yaml b/charts/ix-chart/2009.0.1/questions.yaml index dcf5f59ee66..89752e9bba5 100644 --- a/charts/ix-chart/2009.0.1/questions.yaml +++ b/charts/ix-chart/2009.0.1/questions.yaml @@ -63,11 +63,22 @@ label: "Restart Policy" schema: type: string + show_if: [["workloadType", "=", "Deployment"]] default: "Always" enum: - "Always" - "OnFailure" - "Never" +- variable: jobRestartPolicy + description: "Restart Policy for workload" + label: "Restart Policy" + schema: + type: string + default: "OnFailure" + show_if: [["workloadType", "!=", "Deployment"]] + enum: + - "OnFailure" + - "Never" # Configurable CMD / Entrypoint / Environment Variables - variable: containerCommand diff --git a/charts/ix-chart/2009.0.1/templates/_helpers.tpl b/charts/ix-chart/2009.0.1/templates/_helpers.tpl index 17020dbe860..ae3992f00f1 100644 --- a/charts/ix-chart/2009.0.1/templates/_helpers.tpl +++ b/charts/ix-chart/2009.0.1/templates/_helpers.tpl @@ -96,3 +96,15 @@ Get API Version based on workload type {{- printf "batch/v1" }} {{- end }} {{- end }} + + +{{/* +Get Restart policy based on workload type +*/}} +{{- define "restartPolicy" -}} +{{- if eq (include "workloadIsDeployment" .) "true" }} +{{- printf "%s" .Values.restartPolicy }} +{{- else }} +{{- printf "%s" .Values.jobRestartPolicy }} +{{- end }} +{{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/deployment.yaml b/charts/ix-chart/2009.0.1/templates/deployment.yaml index 8d04b133a92..ba216f7df47 100644 --- a/charts/ix-chart/2009.0.1/templates/deployment.yaml +++ b/charts/ix-chart/2009.0.1/templates/deployment.yaml @@ -5,13 +5,13 @@ metadata: labels: {{- include "ix-chart.labels" . | nindent 4 }} spec: - {{- if eq .Values.workloadType "Deployment" }} + {{- if eq (include "workloadIsDeployment" .) "true" }} strategy: type: {{ .Values.updateStrategy }} - {{- end }} selector: matchLabels: {{- include "ix-chart.selectorLabels" . | nindent 6 }} + {{- end }} template: metadata: labels: @@ -22,7 +22,7 @@ spec: k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }} {{- end }} spec: - restartPolicy: {{ .Values.restartPolicy | quote }} + restartPolicy: {{ template "restartPolicy" . }} containers: - name: {{ .Chart.Name }} {{- if or .Values.hostPathVolumes .Values.persistentVolumeClaims }} diff --git a/charts/ix-chart/2009.0.1/values.yaml b/charts/ix-chart/2009.0.1/values.yaml index 1174db8a09b..2c2b0484492 100644 --- a/charts/ix-chart/2009.0.1/values.yaml +++ b/charts/ix-chart/2009.0.1/values.yaml @@ -6,9 +6,6 @@ image: # Overrides the image tag whose default is the chart appVersion. tag: "testing" -# Restart Policy -restartPolicy: "Always" - # Container CMD / entrypoint containerCommand: [] containerArgs: []