Merge branch 'develop'

This commit is contained in:
Chi-En Wu
2020-04-24 10:21:22 +08:00
16 changed files with 1155 additions and 46 deletions

View File

@ -14,4 +14,4 @@ type: library
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
version: 0.2.0 version: 0.3.0

1119
README.md

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
data: {} data: {}
{{- end -}} {{- end -}}

View File

@ -6,11 +6,11 @@
{{- $image := $container.image | default (dict) -}} {{- $image := $container.image | default (dict) -}}
name: {{ $top.Chart.Name }} name: {{ $top.Chart.Name }}
securityContext: securityContext:
{{- toYaml $container.securityContext | nindent 4 }} {{- toYaml $container.securityContext | nindent 2 }}
image: "{{ $image.repository }}:{{ $image.tag | default $top.Chart.AppVersion }}" image: "{{ $image.repository }}:{{ $image.tag | default $top.Chart.AppVersion }}"
imagePullPolicy: {{ $container.image.pullPolicy }} imagePullPolicy: {{ $container.image.pullPolicy }}
resources: resources:
{{- toYaml $container.resources | nindent 4 }} {{- toYaml $container.resources | nindent 2 }}
{{- end -}} {{- end -}}
{{- define "common.container" -}} {{- define "common.container" -}}

View File

@ -9,10 +9,11 @@ spec:
{{- $top := first . -}} {{- $top := first . -}}
{{- $cronJob := index . 1 -}} {{- $cronJob := index . 1 -}}
{{- $pod := index . 2 -}} {{- $pod := index . 2 -}}
{{- $serviceAccount := index . 3 -}}
apiVersion: batch/v1beta1 apiVersion: batch/v1beta1
kind: CronJob kind: CronJob
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
spec: spec:
schedule: "{{ $cronJob.schedule }}" schedule: "{{ $cronJob.schedule }}"
{{- with $cronJob.concurrencyPolicy }} {{- with $cronJob.concurrencyPolicy }}
@ -27,10 +28,10 @@ spec:
jobTemplate: jobTemplate:
metadata: metadata:
labels: labels:
{{ include "common.selectorLabels" $top | nindent 8 }} {{- include "common.selectorLabels" $top | nindent 8 }}
spec: spec:
template: template:
{{ include "common.pod.template" (list $top $pod "common.cronJob.pod") | nindent 8 }} {{- include "common.pod.template" (list $top $pod $serviceAccount "common.cronJob.pod") | nindent 8 }}
{{- end -}} {{- end -}}
{{- define "common.cronJob" -}} {{- define "common.cronJob" -}}

View File

@ -4,19 +4,20 @@
{{- $top := first . -}} {{- $top := first . -}}
{{- $deployment := index . 1 -}} {{- $deployment := index . 1 -}}
{{- $autoscaling := index . 2 -}} {{- $autoscaling := index . 2 -}}
{{- $serviceAccount := index . 3 -}}
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
spec: spec:
{{- if not $autoscaling.enabled }} {{- if not $autoscaling.enabled }}
replicas: {{ $deployment.replicaCount | default 1 }} replicas: {{ $deployment.replicaCount | default 1 }}
{{- end }} {{- end }}
selector: selector:
matchLabels: matchLabels:
{{ include "common.selectorLabels" $top | nindent 6 }} {{- include "common.selectorLabels" $top | nindent 6 }}
template: template:
{{ include "common.pod.template" . | nindent 4 }} {{- include "common.pod.template" (list $top $deployment $serviceAccount) | nindent 4 }}
{{- end -}} {{- end -}}
{{- define "common.deployment" -}} {{- define "common.deployment" -}}

View File

@ -6,7 +6,7 @@
apiVersion: autoscaling/v2beta2 apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
spec: spec:
scaleTargetRef: scaleTargetRef:
apiVersion: apps/v1 apiVersion: apps/v1

View File

@ -21,7 +21,7 @@ apiVersion: extensions/v1beta1
{{- end }} {{- end }}
kind: Ingress kind: Ingress
metadata: metadata:
{{ include "common.metadata" (append . "common.ingress.metadata") | nindent 2 }} {{- include "common.metadata" (append . "common.ingress.metadata") | nindent 2 }}
spec: spec:
{{- if $ingress.tls }} {{- if $ingress.tls }}
tls: tls:

View File

@ -20,7 +20,7 @@ app.kubernetes.io/name: {{ include "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}} {{- end -}}
{{ define "common.metadata.tpl" -}} {{- define "common.metadata.tpl" -}}
{{- $top := first . -}} {{- $top := first . -}}
name: {{ include "common.fullname" $top }} name: {{ include "common.fullname" $top }}
labels: labels:
@ -30,6 +30,6 @@ labels:
{{- /* {{- /*
Create a standard metadata header Create a standard metadata header
*/ -}} */ -}}
{{ define "common.metadata" -}} {{- define "common.metadata" -}}
{{- include "common.utils.merge" (append . "common.metadata.tpl") -}} {{- include "common.utils.merge" (append . "common.metadata.tpl") -}}
{{- end -}} {{- end -}}

View File

@ -32,25 +32,14 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/*
Common labels
*/}}
{{- define "common.labels" -}}
helm.sh/chart: {{ include "common.chart" . }}
{{ include "common.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/* {{/*
Create the name of the service account to use. Create the name of the service account to use.
*/}} */}}
{{- define "common.serviceAccountName" -}} {{- define "common.serviceAccountName" -}}
{{- $serviceAccount := .Values.serviceAccount | default (dict) -}} {{- $top := first . -}}
{{- $serviceAccount := index . 1 -}}
{{- if $serviceAccount.create -}} {{- if $serviceAccount.create -}}
{{ default (include "common.fullname" .) $serviceAccount.name }} {{ default (include "common.fullname" $top) $serviceAccount.name }}
{{- else -}} {{- else -}}
{{ default "default" $serviceAccount.name }} {{ default "default" $serviceAccount.name }}
{{- end -}} {{- end -}}

View File

@ -6,7 +6,7 @@
apiVersion: policy/v1beta1 apiVersion: policy/v1beta1
kind: PodDisruptionBudget kind: PodDisruptionBudget
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
spec: spec:
selector: selector:
matchLabels: matchLabels:
@ -24,9 +24,9 @@ spec:
{{- define "common.pdb" -}} {{- define "common.pdb" -}}
{{- $top := first . -}} {{- $top := first . -}}
{{- $pod := index . 2 -}} {{- $deployment := index . 2 -}}
{{- $autoscaling := index . 3 -}} {{- $autoscaling := index . 3 -}}
{{- if or (and $autoscaling.enabled (gt ($autoscaling.minReplicas | int) 1)) (gt ($pod.replicaCount | int) 1) }} {{- if or (and $autoscaling.enabled (gt ($autoscaling.minReplicas | int) 1)) (and (not $autoscaling.enabled) (gt ($deployment.replicaCount | int) 1)) }}
{{- include "common.utils.merge" (append . "common.pdb.tpl") -}} {{- include "common.utils.merge" (append . "common.pdb.tpl") -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View File

@ -2,29 +2,30 @@
{{- define "common.pod.template.tpl" -}} {{- define "common.pod.template.tpl" -}}
{{- $top := first . -}} {{- $top := first . -}}
{{- $values := index . 1 -}} {{- $pod := index . 1 -}}
{{- $serviceAccount := index . 2 -}}
metadata: metadata:
labels: labels:
{{- include "common.selectorLabels" $top | nindent 4 }} {{- include "common.selectorLabels" $top | nindent 4 }}
spec: spec:
{{- with $values.imagePullSecrets }} {{- with $pod.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
serviceAccountName: {{ include "common.serviceAccountName" $top }} serviceAccountName: {{ include "common.serviceAccountName" (list $top $serviceAccount) }}
securityContext: securityContext:
{{- toYaml $values.podSecurityContext | nindent 4 }} {{- toYaml $pod.podSecurityContext | nindent 4 }}
containers: containers:
- {{- include "common.container" . | nindent 6 }} - {{- include "common.container" (list $top $pod) | nindent 6 }}
{{- with $values.nodeSelector }} {{- with $pod.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with $values.affinity }} {{- with $pod.affinity }}
affinity: affinity:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with $values.tolerations }} {{- with $pod.tolerations }}
tolerations: tolerations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}

View File

@ -5,7 +5,7 @@
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
type: Opaque type: Opaque
data: {} data: {}
{{- end -}} {{- end -}}

View File

@ -6,7 +6,7 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
{{ include "common.metadata" (list $top) | nindent 2 }} {{- include "common.metadata" (list $top) | nindent 2 }}
spec: spec:
type: {{ $service.type }} type: {{ $service.type }}
ports: ports:

View File

@ -3,7 +3,7 @@
{{- define "common.serviceAccount.metadata" -}} {{- define "common.serviceAccount.metadata" -}}
{{- $top := first . -}} {{- $top := first . -}}
{{- $serviceAccount := index . 1 -}} {{- $serviceAccount := index . 1 -}}
name: {{ include "common.serviceAccountName" $top }} name: {{ include "common.serviceAccountName" . }}
{{- with $serviceAccount.annotations }} {{- with $serviceAccount.annotations }}
annotations: annotations:
{{- toYaml . | nindent 2 }} {{- toYaml . | nindent 2 }}
@ -14,7 +14,7 @@ annotations:
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
{{ include "common.metadata" (append . "common.serviceAccount.metadata") | nindent 2 }} {{- include "common.metadata" (append . "common.serviceAccount.metadata") | nindent 2 }}
{{- end -}} {{- end -}}
{{- define "common.serviceAccount" -}} {{- define "common.serviceAccount" -}}

View File

@ -13,7 +13,7 @@ namespace: {{ . }}
apiVersion: monitoring.coreos.com/v1 apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor kind: ServiceMonitor
metadata: metadata:
{{ include "common.metadata" (append . "common.serviceMonitor.metadata") | nindent 2 }} {{- include "common.metadata" (append . "common.serviceMonitor.metadata") | nindent 2 }}
spec: spec:
selector: selector:
matchLabels: matchLabels: