[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
description: Function library for k8s-at-home charts
type: library
version: 1.0.5
version: 1.1.0
keywords:
- k8s-at-home
- common

View File

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

View File

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

View File

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

View File

@ -1,5 +1,19 @@
{{- define "common.service" -}}
{{- if .Values.service.enabled -}}
{{- /* Generate primary 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 }}

View File

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

View File

@ -2,12 +2,12 @@
The OpenVPN shared volume to be inserted
*/}}
{{- 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
configMap:
name: {{ template "common.names.fullname" . }}-vpn
items:
{{- if .Values.addons.vpn.vpnConf }}
{{- if .Values.addons.vpn.configFile }}
- key: vpnConfigfile
path: vpnConfigfile
{{- end }}

View File

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

View File

@ -1,5 +1,12 @@
# type: options are statefulset or deployment
controllerType: deployment
# Set annotations on the deployment/statefulset
controllerAnnotations: {}
# Set labels on the deployment/statefulset
controllerLabels: {}
# Set annotations on the pod
podAnnotations: {}
env: {}
@ -47,6 +54,21 @@ service:
annotations: {}
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:
enabled: false
annotations: {}