Move common metadata to separate method

This commit is contained in:
Waqar Ahmed 2020-10-08 18:45:19 +05:00
parent 6716877fa7
commit 5021882066
2 changed files with 18 additions and 14 deletions

View File

@ -58,10 +58,10 @@ containers:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- include "containerCommand" | indent 2 }} {{- include "containerCommand" . | indent 2 }}
{{- include "containerArgs" | indent 2 }} {{- include "containerArgs" . | indent 2 }}
{{- include "containerEnvVariables" | indent 2 }} {{- include "containerEnvVariables" . | indent 2 }}
{{- include "containerLivenssProbe" | indent 2 }} {{- include "containerLivenssProbe" . | indent 2 }}
{{- include "volumeConfiguration" . }} {{- include "volumeConfiguration" . }}
{{- end }} {{- end }}
@ -77,6 +77,16 @@ k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurat
{{- end }} {{- end }}
{{/*
Metadata for workload
*/}}
{{- define "commonMetadataWorkload" }}
labels:
{{- include "ix-chart.selectorLabels" . | nindent 2 }}
annotations:
{{- include "workloadAnnotations" . | nindent 2 }}
{{- end }}
{{/* {{/*
Deployment Spec Deployment Spec
*/}} */}}
@ -88,10 +98,7 @@ matchLabels:
{{- include "ix-chart.selectorLabels" . | nindent 2 }} {{- include "ix-chart.selectorLabels" . | nindent 2 }}
template: template:
metadata: metadata:
labels: {{ include "commonMetadataWorkload" . | nindent 4 }}
{{- include "ix-chart.selectorLabels" . | nindent 6 }}
annotations:
{{- include "workloadAnnotations" . | nindent 6 }}
spec: spec:
{{- include "podSepc" . | indent 4 }} {{- include "podSepc" . | indent 4 }}
{{- end }} {{- end }}
@ -102,10 +109,7 @@ Job Spec Common
*/}} */}}
{{- define "jobSpecCommon" }} {{- define "jobSpecCommon" }}
metadata: metadata:
labels: {{ include "commonMetadataWorkload" . | nindent 4 }}
{{- include "ix-chart.selectorLabels" . | nindent 4 }}
annotations:
{{- include "workloadAnnotations" . | nindent 4 }}
spec: spec:
{{- include "podSepc" . | indent 2 }} {{- include "podSepc" . | indent 2 }}
{{- end }} {{- end }}

View File

@ -6,8 +6,8 @@ metadata:
{{- include "ix-chart.labels" . | nindent 4 }} {{- include "ix-chart.labels" . | nindent 4 }}
spec: spec:
{{- if eq (include "workloadIsDeployment" .) "true" }} {{- if eq (include "workloadIsDeployment" .) "true" }}
{{ include "deploymentSpec" | nindent 2 }} {{ include "deploymentSpec" . | nindent 2 }}
{{- else if ne (include "workloadIsCronJob" .) "true" }} {{- else if eq (include "workloadIsCronJob" .) "true" }}
{{ include "cronJobSpec" . | nindent 2 }} {{ include "cronJobSpec" . | nindent 2 }}
{{- else }}} {{- else }}}
{{ include "jobSpec" . | nindent 2 }} {{ include "jobSpec" . | nindent 2 }}