diff --git a/charts/workload/Chart.yaml b/charts/workload/Chart.yaml index a7f1508..52e433f 100644 --- a/charts/workload/Chart.yaml +++ b/charts/workload/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: softplayer-lib-workload description: A library to be reused accross softplayer charts type: library -version: 0.1.7 +version: 0.1.8 maintainers: - name: allanger email: allanger@badhouseplants.net diff --git a/charts/workload/templates/deployment/_containers.tpl b/charts/workload/templates/deployment/_containers.tpl index 4b15c5d..b3ed8db 100644 --- a/charts/workload/templates/deployment/_containers.tpl +++ b/charts/workload/templates/deployment/_containers.tpl @@ -3,15 +3,8 @@ {{ fail ".Values.workload.containers can not be empty (heler.deployment.containers)" }} {{- end -}} {{- /* /(1) */ -}} containers: -{{- range $k,$v := .Values.workload.containers }} {{- /* (1) */}} - - name: {{ $k }} - {{- include "helper.workload.containerSecurityContext" . | nindent 4 -}} - {{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}} - {{- include "helper.container.command" $v | nindent 4 -}} - {{- include "helper.container.args" $v | nindent 4 -}} - {{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}} - {{- include "helper.container.volumeMounts" $v | nindent 4 -}} - {{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}} +{{- range $k, $v := .Values.workload.containers }} {{- /* (1) */}} +{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}} {{- end }} {{- /* /(1) */}} {{- end -}} {{- /* /(define) */ -}} @@ -19,20 +12,24 @@ containers: {{- if .Values.workload.initContainers -}} {{- /* (1) */ -}} initContainers: {{- range $k,$v := .Values.workload.initContainers }} {{- /* (2) */}} - - name: {{ $k }} - {{- include "helper.workload.containerSecurityContext" . | nindent 4 -}} - {{- include "helper.workload.image" (dict "Chart" $.Chart "Image" .image) | indent 4 -}} - {{- include "helper.container.command" $v | nindent 4 -}} - {{- include "helper.container.args" $v | nindent 4 -}} - {{- include "helper.container.ports" (dict "Context" $ "Container" $v) | nindent 4 -}} - {{- include "helper.container.volumeMounts" $v | nindent 4 -}} - {{- include "helper.container.envFrom" (dict "Context" $ "Container" $v) | nindent 4 -}} +{{ include "helper.deployment.container" (dict "Context" $ "ContainerName" $k "ContainerData" $v) | indent 2}} {{- end }} {{- /* /(1) */}} {{- end -}} {{- /* /(2) */ -}} {{- end -}} {{- /* /(define) */ -}} {{- define "helper.deployment.container" -}} {{- /* (define) */ -}} +- name: {{ .ContainerName }} + {{- include "helper.workload.containerSecurityContext" .ContainerData | nindent 2 -}} + {{- include "helper.workload.image" (dict "Chart" .Context.Chart "Image" .ContainerData.image) | indent 2 -}} + {{- include "helper.container.command" .ContainerData | nindent 2 -}} + {{- include "helper.container.args" .ContainerData | nindent 2 -}} + {{- include "helper.container.ports" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}} + {{- include "helper.container.volumeMounts" .ContainerData | nindent 2 -}} + {{- include "helper.container.envFrom" (dict "Context" .Context "Container" .ContainerData) | nindent 2 -}} + {{- include "helper.container.livenessProbe" .ContainerData | nindent 2 -}} + {{- include "helper.container.readinessProbe" .ContainerData | nindent 2 -}} + {{- include "helper.container.startupProbe" .ContainerData | nindent 2 -}} {{- end -}} {{- /* /(define) */ -}} {{- define "helper.container.command" -}} {{- /* (define) */ -}} @@ -118,3 +115,25 @@ envFrom: {{- end -}} {{- /* /(2) */ -}} {{- end -}} {{- /* /(1) */ -}} {{- end -}} {{- /* /(define) */ -}} + +{{- /* Probes */ -}} +{{- define "helper.container.readinessProbe" -}} {{- /* (define) */ -}} +{{- if .readinessProbe }} {{- /* (1) */}} +readinessProbe: +{{ .readinessProbe | toYaml | indent 2 }} +{{- end }} {{- /* /(0) */}} +{{- end -}} {{- /* /(define) */ -}} + +{{- define "helper.container.livenessProbe" -}} {{- /* (define) */ -}} +{{- if .livenessProbe }} {{- /* (1) */}} +livenessProbe: +{{ .livenessProbe | toYaml | indent 2 }} +{{- end }} {{- /* /(0) */}} +{{- end -}} {{- /* /(define) */ -}} + +{{- define "helper.container.startupProbe" -}} {{- /* (define) */ -}} +{{- if .startupProbe }} {{- /* (1) */}} +startupProbe: +{{ .startupProbe | toYaml | indent 2 }} +{{- end }} {{- /* /(0) */}} +{{- end -}} {{- /* /(define) */ -}} diff --git a/charts/workload/templates/raw/_raw.tpl b/charts/workload/templates/raw/_raw.tpl new file mode 100644 index 0000000..02cd46b --- /dev/null +++ b/charts/workload/templates/raw/_raw.tpl @@ -0,0 +1,8 @@ +{{- define "lib.raw" -}} +{{- if $.Values.raw -}} + {{- range $.Values.raw }} +---{{- (tpl . $) | nindent 0 }} + {{- end }} +{{- end -}} +{{- end -}} +