feat: extract template common.pod-template

This commit is contained in:
Chi-En Wu
2020-04-20 16:24:08 +08:00
parent 084cef1bc8
commit 6fbe885937
2 changed files with 34 additions and 25 deletions

View File

@ -14,31 +14,7 @@ spec:
matchLabels:
{{- include "common.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "common.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "common.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- {{- include "common.container" . | nindent 10 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "common.pod-template" . | nindent 4 }}
{{- end -}}
{{- define "common.deployment" -}}

33
templates/_pod.tpl Normal file
View File

@ -0,0 +1,33 @@
{{/* vim: set filetype=mustache: */}}
{{- define "common.pod-template.tpl" -}}
metadata:
labels:
{{- include "common.selectorLabels" . | nindent 4 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "common.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 4 }}
containers:
- {{- include "common.container" . | nindent 6 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- define "common.pod-template" -}}
{{- include "common.utils.flattenCall" (list "common.utils.merge" . "common.pod-template.tpl") -}}
{{- end -}}