[common] Add controller labels and annotations (#134)

This commit is contained in:
Bernd Schörgers 2020-11-09 21:50:56 +01:00 committed by GitHub
parent 9a88e697d2
commit 1799d4c057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 9 deletions

View File

@ -2,7 +2,7 @@ apiVersion: v2
name: common name: common
description: Function library for k8s-at-home charts description: Function library for k8s-at-home charts
type: library type: library
version: 1.0.5 version: 1.1.0
keywords: keywords:
- k8s-at-home - k8s-at-home
- common - common

View File

@ -5,6 +5,13 @@ metadata:
name: {{ template "common.names.fullname" . }} name: {{ template "common.names.fullname" . }}
labels: labels:
{{- include "common.labels" . | nindent 4 }} {{- include "common.labels" . | nindent 4 }}
{{- with .Values.controllerLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.controllerAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec: spec:
replicas: 1 replicas: 1
selector: selector:

View File

@ -17,8 +17,8 @@
{{- if not $ingressValues.nameSuffix -}} {{- if not $ingressValues.nameSuffix -}}
{{- $_ := set $ingressValues "nameSuffix" $index -}} {{- $_ := set $ingressValues "nameSuffix" $index -}}
{{ end -}} {{ end -}}
{{- $_ := set . "ObjectValues" (dict "ingress" $ingressValues) -}} {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
{{- include "common.classes.ingress" . -}} {{- include "common.classes.ingress" $ -}}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@ -1,15 +1,14 @@
{{- define "common.pvc" -}} {{- define "common.pvc" -}}
{{- /* Generate pvc as required */ -}} {{- /* Generate pvc as required */ -}}
{{- $context := . -}}
{{- range $index, $PVC := .Values.persistence }} {{- range $index, $PVC := .Values.persistence }}
{{- if and $PVC.enabled (not (or $PVC.emptyDir $PVC.existingClaim)) -}} {{- if and $PVC.enabled (not (or $PVC.emptyDir $PVC.existingClaim)) -}}
{{- $persistenceValues := $PVC -}} {{- $persistenceValues := $PVC -}}
{{- if not $persistenceValues.nameSuffix -}} {{- if not $persistenceValues.nameSuffix -}}
{{- $_ := set $persistenceValues "nameSuffix" $index -}} {{- $_ := set $persistenceValues "nameSuffix" $index -}}
{{- end -}} {{- end -}}
{{- $_ := set $context "ObjectValues" (dict "persistence" $persistenceValues) -}} {{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}}
{{- print ("---") | nindent 0 -}} {{- print ("---") | nindent 0 -}}
{{- include "common.classes.pvc" $context -}} {{- include "common.classes.pvc" $ -}}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@ -1,5 +1,19 @@
{{- define "common.service" -}} {{- define "common.service" -}}
{{- if .Values.service.enabled -}} {{- if .Values.service.enabled -}}
{{- /* Generate primary service */ -}}
{{- include "common.classes.service" . }} {{- include "common.classes.service" . }}
{{- /* Generate additional services as required */ -}}
{{- range $index, $extraService := .Values.service.additionalServices }}
{{- if $extraService.enabled -}}
{{- print ("---") | nindent 0 -}}
{{- $serviceValues := $extraService -}}
{{- if not $serviceValues.nameSuffix -}}
{{- $_ := set $serviceValues "nameSuffix" $index -}}
{{ end -}}
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
{{- include "common.classes.service" $ -}}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View File

@ -5,6 +5,13 @@ metadata:
name: {{ template "common.names.fullname" . }} name: {{ template "common.names.fullname" . }}
labels: labels:
{{- include "common.labels" . | nindent 4 }} {{- include "common.labels" . | nindent 4 }}
{{- with .Values.controllerLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.controllerAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec: spec:
replicas: 1 replicas: 1
selector: selector:

View File

@ -2,12 +2,12 @@
The OpenVPN shared volume to be inserted The OpenVPN shared volume to be inserted
*/}} */}}
{{- define "common.addon.vpn.volume" -}} {{- define "common.addon.vpn.volume" -}}
{{- if or .Values.addons.vpn.vpnConf .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}} {{- if or .Values.addons.vpn.configFile .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}}
name: vpnconfig name: vpnconfig
configMap: configMap:
name: {{ template "common.names.fullname" . }}-vpn name: {{ template "common.names.fullname" . }}-vpn
items: items:
{{- if .Values.addons.vpn.vpnConf }} {{- if .Values.addons.vpn.configFile }}
- key: vpnConfigfile - key: vpnConfigfile
path: vpnConfigfile path: vpnConfigfile
{{- end }} {{- end }}

View File

@ -5,11 +5,15 @@
{{- $values = . -}} {{- $values = . -}}
{{- end -}} {{- end -}}
{{ end -}} {{ end -}}
{{- $serviceName := include "common.names.fullname" . -}}
{{- if hasKey $values "nameSuffix" -}}
{{- $serviceName = printf "%v-%v" $serviceName $values.nameSuffix -}}
{{ end -}}
{{- $svcType := $values.type -}} {{- $svcType := $values.type -}}
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ include "common.names.fullname" . }} name: {{ $serviceName }}
labels: labels:
{{- include "common.labels" . | nindent 4 }} {{- include "common.labels" . | nindent 4 }}
{{- if $values.labels }} {{- if $values.labels }}

View File

@ -1,5 +1,12 @@
# type: options are statefulset or deployment # type: options are statefulset or deployment
controllerType: deployment controllerType: deployment
# Set annotations on the deployment/statefulset
controllerAnnotations: {}
# Set labels on the deployment/statefulset
controllerLabels: {}
# Set annotations on the pod
podAnnotations: {}
env: {} env: {}
@ -47,6 +54,21 @@ service:
annotations: {} annotations: {}
labels: {} labels: {}
additionalServices: []
# - enabled: false
# nameSuffix: api
# type: ClusterIP
# # Specify the default port information
# port:
# port: ""
# name: http
# protocol: TCP
# targetPort: http
# # nodePort:
# additionalPorts: []
# annotations: {}
# labels: {}
ingress: ingress:
enabled: false enabled: false
annotations: {} annotations: {}