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
# 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
kind: ConfigMap
metadata:
{{ include "common.metadata" (list $top) | nindent 2 }}
{{- include "common.metadata" (list $top) | nindent 2 }}
data: {}
{{- end -}}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ app.kubernetes.io/name: {{ include "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{ define "common.metadata.tpl" -}}
{{- define "common.metadata.tpl" -}}
{{- $top := first . -}}
name: {{ include "common.fullname" $top }}
labels:
@ -30,6 +30,6 @@ labels:
{{- /*
Create a standard metadata header
*/ -}}
{{ define "common.metadata" -}}
{{- define "common.metadata" -}}
{{- include "common.utils.merge" (append . "common.metadata.tpl") -}}
{{- 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 "-" -}}
{{- 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.
*/}}
{{- define "common.serviceAccountName" -}}
{{- $serviceAccount := .Values.serviceAccount | default (dict) -}}
{{- $top := first . -}}
{{- $serviceAccount := index . 1 -}}
{{- if $serviceAccount.create -}}
{{ default (include "common.fullname" .) $serviceAccount.name }}
{{ default (include "common.fullname" $top) $serviceAccount.name }}
{{- else -}}
{{ default "default" $serviceAccount.name }}
{{- end -}}

View File

@ -6,7 +6,7 @@
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
{{ include "common.metadata" (list $top) | nindent 2 }}
{{- include "common.metadata" (list $top) | nindent 2 }}
spec:
selector:
matchLabels:
@ -24,9 +24,9 @@ spec:
{{- define "common.pdb" -}}
{{- $top := first . -}}
{{- $pod := index . 2 -}}
{{- $deployment := index . 2 -}}
{{- $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") -}}
{{- end -}}
{{- end -}}

View File

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

View File

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

View File

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

View File

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

View File

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