diff --git a/templates/_configmap.yaml b/templates/_configmap.yaml index 0a603dd..05f70f0 100644 --- a/templates/_configmap.yaml +++ b/templates/_configmap.yaml @@ -3,7 +3,8 @@ {{- define "common.configMap.tpl" -}} apiVersion: v1 kind: ConfigMap -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} data: {} {{- end -}} diff --git a/templates/_deployment.yaml b/templates/_deployment.yaml index e577e0b..16efd93 100644 --- a/templates/_deployment.yaml +++ b/templates/_deployment.yaml @@ -4,7 +4,8 @@ {{- $autoscaling := .Values.autoscaling | default (dict) -}} apiVersion: apps/v1 kind: Deployment -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} spec: {{- if not $autoscaling.enabled }} replicas: {{ .Values.replicaCount | default 1 }} diff --git a/templates/_hpa.yaml b/templates/_hpa.yaml index b3b332a..c1a2baa 100644 --- a/templates/_hpa.yaml +++ b/templates/_hpa.yaml @@ -3,7 +3,8 @@ {{- define "common.hpa.tpl" -}} apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/templates/_ingress.yaml b/templates/_ingress.yaml index 70ffc91..d8638a1 100644 --- a/templates/_ingress.yaml +++ b/templates/_ingress.yaml @@ -1,5 +1,12 @@ {{/* vim: set filetype=mustache: */}} +{{- define "common.ingress.metadata" -}} +{{- with .Values.ingress.annotations }} +annotations: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} + {{- define "common.ingress.tpl" -}} {{- $fullName := include "common.fullname" . -}} {{- $svcPort := .Values.service.port -}} @@ -9,11 +16,8 @@ apiVersion: networking.k8s.io/v1beta1 apiVersion: extensions/v1beta1 {{- end }} kind: Ingress -{{ include "common.metadata" . }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} +metadata: + {{ include "common.metadata" (list . "common.ingress.metadata") | nindent 2 }} spec: {{- if .Values.ingress.tls }} tls: diff --git a/templates/_metadata.tpl b/templates/_metadata.tpl index 15daf64..e20880b 100644 --- a/templates/_metadata.tpl +++ b/templates/_metadata.tpl @@ -20,12 +20,15 @@ app.kubernetes.io/name: {{ include "common.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} +{{ define "common.metadata.tpl" -}} +name: {{ include "common.fullname" . }} +labels: + {{- include "common.labels" . | nindent 2 -}} +{{- end -}} + {{- /* Create a standard metadata header */ -}} {{ define "common.metadata" -}} -metadata: - name: {{ include "common.fullname" . }} - labels: - {{- include "common.labels" . | nindent 4 -}} +{{- include "common.utils.flattenCall" (list "common.utils.merge" . "common.metadata.tpl") -}} {{- end -}} diff --git a/templates/_pdb.yaml b/templates/_pdb.yaml index 5e6382a..21699fe 100644 --- a/templates/_pdb.yaml +++ b/templates/_pdb.yaml @@ -3,7 +3,8 @@ {{- define "common.pdb.tpl" -}} apiVersion: policy/v1beta1 kind: PodDisruptionBudget -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} spec: selector: matchLabels: diff --git a/templates/_secret.yaml b/templates/_secret.yaml index 0d25ed9..37b19f9 100644 --- a/templates/_secret.yaml +++ b/templates/_secret.yaml @@ -3,7 +3,8 @@ {{- define "common.secret.tpl" -}} apiVersion: v1 kind: Secret -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} type: Opaque data: {} {{- end -}} diff --git a/templates/_service.yaml b/templates/_service.yaml index 082ff27..eb3d299 100644 --- a/templates/_service.yaml +++ b/templates/_service.yaml @@ -3,7 +3,8 @@ {{- define "common.service.tpl" -}} apiVersion: v1 kind: Service -{{ include "common.metadata" . }} +metadata: + {{ include "common.metadata" . | nindent 2 }} spec: type: {{ .Values.service.type }} ports: diff --git a/templates/_serviceaccount.yaml b/templates/_serviceaccount.yaml index 2837ac8..8209b09 100644 --- a/templates/_serviceaccount.yaml +++ b/templates/_serviceaccount.yaml @@ -1,16 +1,18 @@ {{/* vim: set filetype=mustache: */}} +{{- define "common.serviceAccount.metadata" -}} +name: {{ include "common.serviceAccountName" . }} +{{- with .Values.serviceAccount.annotations }} +annotations: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} + {{- define "common.serviceAccount.tpl" -}} apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "common.serviceAccountName" . }} - labels: - {{- include "common.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} + {{ include "common.metadata" (list . "common.serviceAccount.metadata") | nindent 2 }} {{- end -}} {{- define "common.serviceAccount.if" -}}