diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index e2646e2a..7f57fd2a 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -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 diff --git a/charts/common/templates/_deployment.tpl b/charts/common/templates/_deployment.tpl index 694d1800..25b138da 100644 --- a/charts/common/templates/_deployment.tpl +++ b/charts/common/templates/_deployment.tpl @@ -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: diff --git a/charts/common/templates/_ingress.tpl b/charts/common/templates/_ingress.tpl index e771cb19..0a4e3902 100644 --- a/charts/common/templates/_ingress.tpl +++ b/charts/common/templates/_ingress.tpl @@ -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 }} diff --git a/charts/common/templates/_pvc.tpl b/charts/common/templates/_pvc.tpl index e4f523ee..5c35bf03 100644 --- a/charts/common/templates/_pvc.tpl +++ b/charts/common/templates/_pvc.tpl @@ -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 }} diff --git a/charts/common/templates/_service.tpl b/charts/common/templates/_service.tpl index cc0fbeef..6c1fbca3 100644 --- a/charts/common/templates/_service.tpl +++ b/charts/common/templates/_service.tpl @@ -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 }} diff --git a/charts/common/templates/_statefulset.tpl b/charts/common/templates/_statefulset.tpl index c18568bf..cb0f5e8c 100644 --- a/charts/common/templates/_statefulset.tpl +++ b/charts/common/templates/_statefulset.tpl @@ -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: diff --git a/charts/common/templates/addons/vpn/_volume.tpl b/charts/common/templates/addons/vpn/_volume.tpl index de2016e5..5d5d162c 100644 --- a/charts/common/templates/addons/vpn/_volume.tpl +++ b/charts/common/templates/addons/vpn/_volume.tpl @@ -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 }} diff --git a/charts/common/templates/classes/_service.tpl b/charts/common/templates/classes/_service.tpl index a326fd33..19b8fd5e 100644 --- a/charts/common/templates/classes/_service.tpl +++ b/charts/common/templates/classes/_service.tpl @@ -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 }} diff --git a/charts/common/values.yaml b/charts/common/values.yaml index 132901ee..784e627c 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -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: {}