feat: allow common.metadata to be extended

This commit is contained in:
Chi-En Wu
2020-04-17 11:19:01 +08:00
parent 2d3734c769
commit 5fb7898e1b
9 changed files with 37 additions and 22 deletions

View File

@ -3,7 +3,8 @@
{{- define "common.configMap.tpl" -}}
apiVersion: v1
kind: ConfigMap
{{ include "common.metadata" . }}
metadata:
{{ include "common.metadata" . | nindent 2 }}
data: {}
{{- end -}}

View File

@ -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 }}

View File

@ -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

View File

@ -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:

View File

@ -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 -}}

View File

@ -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:

View File

@ -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 -}}

View File

@ -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:

View File

@ -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" -}}