diff --git a/charts/ix-chart/2009.0.1/templates/_containers.tpl b/charts/ix-chart/2009.0.1/templates/_containers.tpl new file mode 100644 index 00000000000..95e9a2bc886 --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/_containers.tpl @@ -0,0 +1,50 @@ +{{/* +Container Command +*/}} +{{- define "containerCommand" }} +{{- if .Values.containerCommand }} +command: + {{- range .Values.containerCommand }} + - {{ . | quote}} + {{- end }} +{{- end }} +{{- end }} + +{{/* +Container Args +*/}} +{{- define "containerArgs" }} +{{- if .Values.containerArgs }} +args: + {{- range .Values.containerArgs }} + - {{ . | quote}} + {{- end }} +{{- end }} +{{- end }} + +{{/* +Container Environment Variables +*/}} +{{- define "containerEnvVariables" }} +{{- if .Values.containerEnvironmentVariables }} +env: + {{- range .Values.containerEnvironmentVariables }} + - name: {{ .name | quote }} + value: {{ .value | quote }} + {{- end }} +{{- end }} +{{- end }} + +{{/* +Container Liveness Probe +*/}} +{{- define "containerLivenssProbe" }} +{{- if .Values.livenessProbe }} +livenessProbe: + exec: + command: + {{ toYaml .Values.livenessProbe.command | indent 16 }} + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.periodSeconds }} +{{- end }} +{{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/_helpers.tpl b/charts/ix-chart/2009.0.1/templates/_helpers.tpl index ae3992f00f1..cc466748a14 100644 --- a/charts/ix-chart/2009.0.1/templates/_helpers.tpl +++ b/charts/ix-chart/2009.0.1/templates/_helpers.tpl @@ -61,50 +61,3 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} - -{{/* -Check if workload type is a deployment -*/}} -{{- define "workloadIsDeployment" }} -{{- if eq .Values.workloadType "Deployment" }} -{{- true -}} -{{- else }} -{{- false -}} -{{- end }} -{{- end }} - -{{/* -Check if workload type is a cronjob -*/}} -{{- define "workloadIsCronJob" }} -{{- if eq .Values.workloadType "CronJob" }} -{{- true -}} -{{- else }} -{{- false -}} -{{- end }} -{{- end }} - -{{/* -Get API Version based on workload type -*/}} -{{- define "apiVersion" -}} -{{- if eq (include "workloadIsDeployment" .) "true" }} -{{- printf "apps/v1" }} -{{- else if eq (include "workloadIsCronJob" .) "true" }} -{{- printf "batch/v1beta1" }} -{{- else }} -{{- 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/_volumes.tpl b/charts/ix-chart/2009.0.1/templates/_volumes.tpl new file mode 100644 index 00000000000..d40799b294a --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/_volumes.tpl @@ -0,0 +1,36 @@ +{{/* +Volumes Configuration +*/}} +{{- define "volumeConfiguration" }} +{{- if or .Values.persistentVolumeClaims .Values.hostPathVolumes }} +volumes: +{{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} + - name: ix-host-path-{{ $.Release.Name }}-{{ $index }} + hostPath: + path: {{ $hostPathConfiguration.hostPath }} +{{- end }} +{{- range $index, $claim := .Values.persistentVolumeClaims }} + - name: ix-pv-{{ $.Release.Name }}-{{ $index }} + persistentVolumeClaim: + claimName: ix-pv-claim-{{ $.Release.Name }}-{{ $index }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Volume Mounts Configuration +*/}} +{{- define "volumeMountsConfiguration" }} +{{- if or .Values.hostPathVolumes .Values.persistentVolumeClaims }} +volumeMounts: + {{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} + - mountPath: {{ $hostPathConfiguration.mountPath }} + name: ix-host-path-{{ $.Release.Name }}-{{ $index }} + readOnly: {{ $hostPathConfiguration.readOnly }} + {{- end }} + {{- range $index, $claim := .Values.persistentVolumeClaims }} + - mountPath: {{ $claim.mountPath }} + name: ix-pv-{{ $.Release.Name }}-{{ $index }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/_workload.tpl b/charts/ix-chart/2009.0.1/templates/_workload.tpl new file mode 100644 index 00000000000..39e4e9e18af --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/_workload.tpl @@ -0,0 +1,130 @@ +{{/* +Check if workload type is a deployment +*/}} +{{- define "workloadIsDeployment" }} +{{- if eq .Values.workloadType "Deployment" }} +{{- true -}} +{{- else }} +{{- false -}} +{{- end }} +{{- end }} + +{{/* +Check if workload type is a cronjob +*/}} +{{- define "workloadIsCronJob" }} +{{- if eq .Values.workloadType "CronJob" }} +{{- true -}} +{{- else }} +{{- false -}} +{{- end }} +{{- end }} + +{{/* +Get API Version based on workload type +*/}} +{{- define "apiVersion" -}} +{{- if eq (include "workloadIsDeployment" .) "true" }} +{{- printf "apps/v1" }} +{{- else if eq (include "workloadIsCronJob" .) "true" }} +{{- printf "batch/v1beta1" }} +{{- else }} +{{- 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 }} + + +{{/* +Pod specification +*/}} +{{- define "podSepc" }} +restartPolicy: {{ template "restartPolicy" . }} +containers: +- name: {{ .Chart.Name }} + {{- include "volumeMountsConfiguration" . | indent 2}} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- include "containerCommand" | indent 2 }} + {{- include "containerArgs" | indent 2 }} + {{- include "containerEnvVariables" | indent 2 }} + {{- include "containerLivenssProbe" | indent 2 }} +{{- include "volumeConfiguration" . }} +{{- end }} + + +{{/* +Annotations for workload +*/}} +{{- define "workloadAnnotations" }} +rollme: {{ randAlphaNum 5 | quote }} +{{- if .Values.ixExternalInterfacesConfigurationNames }} +k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }} +{{- end }} +{{- end }} + + +{{/* +Deployment Spec +*/}} +{{- define "deploymentSpec" }} +strategy: + type: {{ .Values.updateStrategy }} +selector: +matchLabels: + {{- include "ix-chart.selectorLabels" . | nindent 2 }} +template: + metadata: + labels: + {{- include "ix-chart.selectorLabels" . | nindent 6 }} + annotations: + {{- include "workloadAnnotations" . | nindent 6 }} + spec: + {{- include "podSepc" . | indent 4 }} +{{- end }} + + +{{/* +Job Spec Common +*/}} +{{- define "jobSpecCommon" }} +metadata: + labels: + {{- include "ix-chart.selectorLabels" . | nindent 4 }} + annotations: + {{- include "workloadAnnotations" . | nindent 4 }} +spec: + {{- include "podSepc" . | indent 2 }} +{{- end }} + + +{{/* +Job Spec +*/}} +{{- define "jobSpec" }} +template: +{{ include "jobSpecCommon" . | nindent 2 }} +{{- end }} + +{{/* +CronJob Spec +*/}} +{{- define "cronJobSpec" }} +schedule: {{ .Values.cronSchedule | quote }} +jobTemplate: + spec: + {{ include "jobSpec" . | nindent 4 }} +{{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/deployment.yaml b/charts/ix-chart/2009.0.1/templates/deployment.yaml deleted file mode 100644 index a7f8398b4d5..00000000000 --- a/charts/ix-chart/2009.0.1/templates/deployment.yaml +++ /dev/null @@ -1,88 +0,0 @@ -apiVersion: {{ template "apiVersion" . }} -kind: {{ .Values.workloadType }} -metadata: - name: {{ include "ix-chart.fullname" . }} - labels: - {{- include "ix-chart.labels" . | nindent 4 }} -spec: - {{- if eq (include "workloadIsDeployment" .) "true" }} - strategy: - type: {{ .Values.updateStrategy }} - selector: - matchLabels: - {{- include "ix-chart.selectorLabels" . | nindent 6 }} - {{- end }} - {{- if ne (include "workloadIsCronJob" .) "true" }} - template: - {{- else }} - schedule: {{ .Values.cronSchedule | quote }} - jobTemplate: - {{- end }} - metadata: - labels: - {{- include "ix-chart.selectorLabels" . | nindent 8 }} - annotations: - rollme: {{ randAlphaNum 5 | quote }} - {{- if .Values.ixExternalInterfacesConfigurationNames }} - k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }} - {{- end }} - spec: - restartPolicy: {{ template "restartPolicy" . }} - containers: - - name: {{ .Chart.Name }} - {{- if or .Values.hostPathVolumes .Values.persistentVolumeClaims }} - volumeMounts: - {{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} - - mountPath: {{ $hostPathConfiguration.mountPath }} - name: ix-host-path-{{ $.Release.Name }}-{{ $index }} - readOnly: {{ $hostPathConfiguration.readOnly }} - {{- end }} - {{- range $index, $claim := .Values.persistentVolumeClaims }} - - mountPath: {{ $claim.mountPath }} - name: ix-pv-{{ $.Release.Name }}-{{ $index }} - {{- end }} - {{- end }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - {{- if .Values.containerCommand }} - command: - {{- range .Values.containerCommand }} - - {{ . | quote}} - {{- end }} - {{- end }} - {{- if .Values.containerArgs }} - args: - {{- range .Values.containerArgs }} - - {{ . | quote}} - {{- end }} - {{- end }} - {{- if .Values.containerEnvironmentVariables }} - env: - {{- range .Values.containerEnvironmentVariables }} - - name: {{ .name | quote }} - value: {{ .value | quote }} - {{- end }} - {{- end }} - {{- if .Values.livenessProbe }} - livenessProbe: - exec: - command: - {{ toYaml .Values.livenessProbe.command | indent 16 }} - initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} - periodSeconds: {{ .Values.periodSeconds }} - {{- end }} - {{- if or .Values.persistentVolumeClaims .Values.hostPathVolumes }} - volumes: - {{- range $index, $hostPathConfiguration := .Values.hostPathVolumes }} - - name: ix-host-path-{{ $.Release.Name }}-{{ $index }} - hostPath: - path: {{ $hostPathConfiguration.hostPath }} - {{- end }} - {{- range $index, $claim := .Values.persistentVolumeClaims }} - - name: ix-pv-{{ $.Release.Name }}-{{ $index }} - persistentVolumeClaim: - claimName: ix-pv-claim-{{ $.Release.Name }}-{{ $index }} - {{- end }} - {{- end }} diff --git a/charts/ix-chart/2009.0.1/templates/workload.yaml b/charts/ix-chart/2009.0.1/templates/workload.yaml new file mode 100644 index 00000000000..5ec39c6a8de --- /dev/null +++ b/charts/ix-chart/2009.0.1/templates/workload.yaml @@ -0,0 +1,14 @@ +apiVersion: {{ template "apiVersion" . }} +kind: {{ .Values.workloadType }} +metadata: + name: {{ include "ix-chart.fullname" . }} + labels: + {{- include "ix-chart.labels" . | nindent 4 }} +spec: + {{- if eq (include "workloadIsDeployment" .) "true" }} + {{ include "deploymentSpec" | nindent 2 }} + {{- else if ne (include "workloadIsCronJob" .) "true" }} + {{ include "cronJobSpec" . | nindent 2 }} + {{- else }}} + {{ include "jobSpec" . | nindent 2 }} + {{- end }}