From 6fbe88593795c1da40a6ab5f42062b631e64c761 Mon Sep 17 00:00:00 2001 From: Chi-En Wu Date: Mon, 20 Apr 2020 16:24:08 +0800 Subject: [PATCH] feat: extract template `common.pod-template` --- templates/_deployment.yaml | 26 +------------------------- templates/_pod.tpl | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 25 deletions(-) create mode 100644 templates/_pod.tpl diff --git a/templates/_deployment.yaml b/templates/_deployment.yaml index 16efd93..5f4e448 100644 --- a/templates/_deployment.yaml +++ b/templates/_deployment.yaml @@ -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" -}} diff --git a/templates/_pod.tpl b/templates/_pod.tpl new file mode 100644 index 0000000..ca2b38d --- /dev/null +++ b/templates/_pod.tpl @@ -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 -}}