diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index c790adf4..765fca4b 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.5.1 +version: 1.6.0 keywords: - k8s-at-home - common diff --git a/charts/common/README.md b/charts/common/README.md index ee21bded..eba4cbd8 100644 --- a/charts/common/README.md +++ b/charts/common/README.md @@ -1,7 +1,10 @@ # Library chart for k8s@home media charts -## **THIS CHART IS NOT MEANT TO BE INSTALLED DIRECTLY** -This is a [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm) for grouping common logic between k8s@home charts. +**WARNING: THIS CHART IS NOT MEANT TO BE INSTALLED DIRECTLY** + +This is a [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm). It's purpose is for grouping common logic between the k8s@home charts. + +Since a lot of charts follow the same pattern this library was built to reduce maintenance cost between the charts that use it and try achieve a goal of being DRY. ## Introduction @@ -9,22 +12,84 @@ This chart provides common template helpers which can be used to develop new cha ## TL;DR +When using one of the many charts that uses this library be sure to view this [values.yaml](./values.yaml) for configuration options. Any setting here can be used to define what values your helm deployment will use. + +For example using the helm CLI tool + +```bash +helm install node-red \ + --set image.repository="nodered/node-red" \ + --set image.tag="1.2.5" \ + --set env.TZ="America/New_York" \ + k8s-at-home/node-red +``` + +or + ```yaml -dependencies: - - name: common - version: 0.x.x - repository: https://k8s-at-home.com/charts/ +# node-red-values.yaml +image: + repository: nodered/node-red + tag: 1.2.5 +env: + TZ: America/New_York ``` ```bash -$ helm dependency update +helm install node-red \ + --values=./node-red-values.yaml \ + k8s-at-home/node-red ``` +## Creating a new chart + +First be sure to checkout the many charts that already use this like [qBittorrent](../qbittorrent/), [node-red](../node-red/) or the many others in this repository. + +Include this chart as a dependency in your `Chart.yaml` e.g. + ```yaml -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "common.names.fullname" . }} -data: - myvalue: "Hello World" +# Chart.yaml +dependencies: + - name: common + version: x.x.x + repository: https://k8s-at-home.com/charts/ +``` + +Write a `values.yaml` with some basic defaults you want to present to the user e.g. + +```yaml +# Default values for node-red. + +image: + repository: nodered/node-red + pullPolicy: IfNotPresent + tag: 1.2.5 + +strategy: + type: Recreate + +# See more environment varaibles in the node-red documentation +# https://nodered.org/docs/getting-started/docker +env: {} + # TZ: + # NODE_OPTIONS: + # NODE_RED_ENABLE_PROJECTS: + # NODE_RED_ENABLE_SAFE_MODE: + # FLOWS: + +service: + port: + port: 1880 + +persistence: + data: + enabled: false + emptyDir: false + mountPath: /data +``` + +If testing locally make sure you update the dependencies with: + +```bash +helm dependency update ``` diff --git a/charts/common/templates/_all.tpl b/charts/common/templates/_all.tpl index efc24e51..57b4f4b9 100644 --- a/charts/common/templates/_all.tpl +++ b/charts/common/templates/_all.tpl @@ -1,3 +1,6 @@ +{{/* +Main entrypoint for the common library chart. It will render all underlying templates based on the provided values. +*/}} {{- define "common.all" -}} {{- /* Merge the local chart values and the common chart defaults */ -}} {{- include "common.values.setup" . }} @@ -10,10 +13,16 @@ {{- /* Build the templates */ -}} {{- include "common.pvc" . }} {{- print "---" | nindent 0 -}} - {{- if eq .Values.controllerType "statefulset" }} - {{- include "common.statefulset" . | nindent 0 }} - {{ else }} + {{- if .Values.serviceAccount.create -}} + {{- include "common.serviceAccount" . }} + {{- print "---" | nindent 0 -}} + {{- end -}} + {{- if eq .Values.controllerType "deployment" }} {{- include "common.deployment" . | nindent 0 }} + {{ else if eq .Values.controllerType "daemonset" }} + {{- include "common.daemonset" . | nindent 0 }} + {{ else if eq .Values.controllerType "statefulset" }} + {{- include "common.statefulset" . | nindent 0 }} {{- end -}} {{- print "---" | nindent 0 -}} {{ include "common.service" . | nindent 0 }} diff --git a/charts/common/templates/_daemonset.tpl b/charts/common/templates/_daemonset.tpl new file mode 100644 index 00000000..6dbcd65e --- /dev/null +++ b/charts/common/templates/_daemonset.tpl @@ -0,0 +1,74 @@ +{{/* +This template serves as the blueprint for the DaemonSet objects that are created +within the common library. +*/}} +{{- define "common.daemonset" -}} +apiVersion: {{ include "common.capabilities.daemonset.apiVersion" . }} +kind: DaemonSet +metadata: + name: {{ include "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: + selector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "common.labels.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "common.names.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.hostNetwork }} + hostNetwork: {{ . }} + {{- end }} + {{- with .Values.dnsPolicy }} + dnsPolicy: {{ . }} + {{- end }} + {{- with .Values.initContainers }} + initContainers: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + {{- include "common.controller.mainContainer" . | nindent 6 }} + {{- with .Values.additionalContainers }} + {{- toYaml . | nindent 6 }} + {{- end }} + volumes: + {{- include "common.controller.volumes" . | trim | nindent 6 }} + {{- with .Values.hostAliases }} + hostAliases: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/charts/common/templates/_deployment.tpl b/charts/common/templates/_deployment.tpl index f76e7a87..eb4faf44 100644 --- a/charts/common/templates/_deployment.tpl +++ b/charts/common/templates/_deployment.tpl @@ -1,8 +1,12 @@ +{{/* +This template serves as the blueprint for the Deployment objects that are created +within the common library. +*/}} {{- define "common.deployment" -}} apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }} kind: Deployment metadata: - name: {{ template "common.names.fullname" . }} + name: {{ include "common.names.fullname" . }} labels: {{- include "common.labels" . | nindent 4 }} {{- with .Values.controllerLabels }} @@ -34,10 +38,17 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} + serviceAccountName: {{ include "common.names.serviceAccountName" . }} {{- with .Values.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.hostNetwork }} + hostNetwork: {{ . }} + {{- end }} + {{- with .Values.dnsPolicy }} + dnsPolicy: {{ . }} + {{- end }} {{- with .Values.initContainers }} initContainers: {{- toYaml . | nindent 8 }} @@ -51,6 +62,10 @@ spec: volumes: {{- include "common.controller.volumes" . | trim | nindent 6 }} + {{- with .Values.hostAliases }} + hostAliases: + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/common/templates/_ingress.tpl b/charts/common/templates/_ingress.tpl index 700d3735..d6ad879a 100644 --- a/charts/common/templates/_ingress.tpl +++ b/charts/common/templates/_ingress.tpl @@ -1,3 +1,7 @@ +{{/* +Renders the Ingress objects required by the chart by returning a concatinated list +of the main Ingress and any additionalIngresses. +*/}} {{- define "common.ingress" -}} {{- if .Values.ingress.enabled -}} {{- $svcPort := .Values.service.port.port -}} diff --git a/charts/common/templates/_pvc.tpl b/charts/common/templates/_pvc.tpl index 5c35bf03..7ad340ba 100644 --- a/charts/common/templates/_pvc.tpl +++ b/charts/common/templates/_pvc.tpl @@ -1,3 +1,7 @@ +{{/* +Renders the PersistentVolumeClaim objects required by the chart by returning a concatinated list +of all the entries of the persistence key. +*/}} {{- define "common.pvc" -}} {{- /* Generate pvc as required */ -}} {{- range $index, $PVC := .Values.persistence }} diff --git a/charts/common/templates/_service.tpl b/charts/common/templates/_service.tpl index 6c1fbca3..2aba616d 100644 --- a/charts/common/templates/_service.tpl +++ b/charts/common/templates/_service.tpl @@ -1,3 +1,7 @@ +{{/* +Renders the Service objects required by the chart by returning a concatinated list +of the main Service and any additionalServices. +*/}} {{- define "common.service" -}} {{- if .Values.service.enabled -}} {{- /* Generate primary service */ -}} diff --git a/charts/common/templates/_serviceaccount.tpl b/charts/common/templates/_serviceaccount.tpl new file mode 100644 index 00000000..a8c0e790 --- /dev/null +++ b/charts/common/templates/_serviceaccount.tpl @@ -0,0 +1,15 @@ +{{/* +The ServiceAccount object to be created. +*/}} +{{- define "common.serviceAccount" -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "common.names.serviceAccountName" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/common/templates/_statefulset.tpl b/charts/common/templates/_statefulset.tpl index d916b529..73d6a123 100644 --- a/charts/common/templates/_statefulset.tpl +++ b/charts/common/templates/_statefulset.tpl @@ -1,8 +1,12 @@ +{{/* +This template serves as the blueprint for the StatefulSet objects that are created +within the common library. +*/}} {{- define "common.statefulset" -}} apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }} kind: StatefulSet metadata: - name: {{ template "common.names.fullname" . }} + name: {{ include "common.names.fullname" . }} labels: {{- include "common.labels" . | nindent 4 }} {{- with .Values.controllerLabels }} @@ -35,6 +39,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} + serviceAccountName: {{ include "common.names.serviceAccountName" . }} {{- with .Values.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} diff --git a/charts/common/templates/addons/vpn/_configmap.tpl b/charts/common/templates/addons/vpn/_configmap.tpl index 48266754..bc5f6902 100644 --- a/charts/common/templates/addons/vpn/_configmap.tpl +++ b/charts/common/templates/addons/vpn/_configmap.tpl @@ -1,12 +1,12 @@ {{/* -The OpenVPN configmaps to be included +The VPN config and scripts to be included. */}} {{- define "common.addon.vpn.configmap" -}} {{- if or .Values.addons.vpn.configFile .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }} apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "common.names.fullname" . }}-vpn + name: {{ include "common.names.fullname" . }}-vpn labels: {{- include "common.labels" . | nindent 4 }} data: diff --git a/charts/common/templates/addons/vpn/_networkpolicy.tpl b/charts/common/templates/addons/vpn/_networkpolicy.tpl index e2b008a2..c707d593 100644 --- a/charts/common/templates/addons/vpn/_networkpolicy.tpl +++ b/charts/common/templates/addons/vpn/_networkpolicy.tpl @@ -1,12 +1,12 @@ {{/* -The OpenVPN networkpolicy to be included +Blueprint for the NetworkPolicy object that can be included in the addon. */}} {{- define "common.addon.vpn.networkpolicy" -}} {{- if .Values.addons.vpn.networkPolicy.enabled -}} kind: NetworkPolicy apiVersion: networking.k8s.io/v1 metadata: - name: {{ template "common.names.fullname" . }} + name: {{ include "common.names.fullname" . }} spec: podSelector: matchLabels: diff --git a/charts/common/templates/addons/vpn/_volume.tpl b/charts/common/templates/addons/vpn/_volume.tpl index 5d5d162c..ac7f83cf 100644 --- a/charts/common/templates/addons/vpn/_volume.tpl +++ b/charts/common/templates/addons/vpn/_volume.tpl @@ -1,11 +1,11 @@ {{/* -The OpenVPN shared volume to be inserted +The volume (referencing VPN config and scripts) to be inserted into additionalVolumes. */}} {{- define "common.addon.vpn.volume" -}} {{- 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 + name: {{ include "common.names.fullname" . }}-vpn items: {{- if .Values.addons.vpn.configFile }} - key: vpnConfigfile diff --git a/charts/common/templates/addons/vpn/_vpn.tpl b/charts/common/templates/addons/vpn/_vpn.tpl index 66b5eee7..e8f028d0 100644 --- a/charts/common/templates/addons/vpn/_vpn.tpl +++ b/charts/common/templates/addons/vpn/_vpn.tpl @@ -1,5 +1,6 @@ {{/* Template to render VPN addon +It will include / inject the required templates based on the given values. */}} {{- define "common.addon.vpn" -}} {{- if .Values.addons.vpn.enabled -}} diff --git a/charts/common/templates/addons/vpn/openvpn/_addon.tpl b/charts/common/templates/addons/vpn/openvpn/_addon.tpl index da84a3e3..62005db4 100644 --- a/charts/common/templates/addons/vpn/openvpn/_addon.tpl +++ b/charts/common/templates/addons/vpn/openvpn/_addon.tpl @@ -1,5 +1,6 @@ {{/* -Template to render OpenVPN addon +Template to render OpenVPN addon. It will add the container to the list of additionalContainers +and add a credentials secret if speciffied. */}} {{- define "common.addon.openvpn" -}} {{/* Append the openVPN container to the additionalContainers */}} diff --git a/charts/common/templates/addons/vpn/openvpn/_container.tpl b/charts/common/templates/addons/vpn/openvpn/_container.tpl index a64423fb..d091ab87 100644 --- a/charts/common/templates/addons/vpn/openvpn/_container.tpl +++ b/charts/common/templates/addons/vpn/openvpn/_container.tpl @@ -1,5 +1,5 @@ {{/* -The OpenVPN container(s) to be inserted +The OpenVPN sidecar container to be inserted. */}} {{- define "common.addon.openvpn.container" -}} name: openvpn @@ -22,7 +22,7 @@ envFrom: {{- if .Values.addons.vpn.openvpn.authSecret }} name: {{ .Values.addons.vpn.openvpn.authSecret }} {{- else }} - name: {{ template "common.names.fullname" . }}-openvpn + name: {{ include "common.names.fullname" . }}-openvpn {{- end }} {{- end }} {{- if or .Values.addons.vpn.configFile .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }} diff --git a/charts/common/templates/addons/vpn/openvpn/_secret.tpl b/charts/common/templates/addons/vpn/openvpn/_secret.tpl index 8b8bd457..3a4deed7 100644 --- a/charts/common/templates/addons/vpn/openvpn/_secret.tpl +++ b/charts/common/templates/addons/vpn/openvpn/_secret.tpl @@ -1,12 +1,12 @@ {{/* -The OpenVPN secrets to be included +The OpenVPN credentials secrets to be included. */}} {{- define "common.addon.openvpn.secret" -}} {{- with .Values.addons.vpn.openvpn.auth -}} apiVersion: v1 kind: Secret metadata: - name: {{ template "common.names.fullname" $ }}-openvpn + name: {{ include "common.names.fullname" $ }}-openvpn labels: {{- include "common.labels" $ | nindent 4 }} data: diff --git a/charts/common/templates/addons/vpn/wireguard/_addon.tpl b/charts/common/templates/addons/vpn/wireguard/_addon.tpl index 1c252ca8..3213b5fa 100644 --- a/charts/common/templates/addons/vpn/wireguard/_addon.tpl +++ b/charts/common/templates/addons/vpn/wireguard/_addon.tpl @@ -1,5 +1,6 @@ {{/* -Template to render Wireguard addon +Template to render Wireguard addon. It will add the container to the list of additionalContainers. +*/}} */}} {{- define "common.addon.wireguard" -}} {{/* Append the Wireguard container to the additionalContainers */}} diff --git a/charts/common/templates/addons/vpn/wireguard/_container.tpl b/charts/common/templates/addons/vpn/wireguard/_container.tpl index 31cb9710..e996cf99 100644 --- a/charts/common/templates/addons/vpn/wireguard/_container.tpl +++ b/charts/common/templates/addons/vpn/wireguard/_container.tpl @@ -1,5 +1,5 @@ {{/* -The Wireguard container(s) to be inserted +The Wireguard sidecar container to be inserted. */}} {{- define "common.addon.wireguard.container" -}} name: wireguard diff --git a/charts/common/templates/classes/_ingress.tpl b/charts/common/templates/classes/_ingress.tpl index 293f30b0..acf8814d 100644 --- a/charts/common/templates/classes/_ingress.tpl +++ b/charts/common/templates/classes/_ingress.tpl @@ -1,3 +1,7 @@ +{{/* +This template serves as a blueprint for all Ingress objects that are created +within the common library. +*/}} {{- define "common.classes.ingress" -}} {{- $ingressName := include "common.names.fullname" . -}} {{- $values := .Values.ingress -}} diff --git a/charts/common/templates/classes/_pvc.tpl b/charts/common/templates/classes/_pvc.tpl index bf06927c..208e7405 100644 --- a/charts/common/templates/classes/_pvc.tpl +++ b/charts/common/templates/classes/_pvc.tpl @@ -1,3 +1,7 @@ +{{/* +This template serves as a blueprint for all PersistentVolumeClaim objects that are created +within the common library. +*/}} {{- define "common.classes.pvc" -}} {{- $values := .Values.persistence -}} {{- if hasKey . "ObjectValues" -}} diff --git a/charts/common/templates/classes/_service.tpl b/charts/common/templates/classes/_service.tpl index 395dff15..d6501457 100644 --- a/charts/common/templates/classes/_service.tpl +++ b/charts/common/templates/classes/_service.tpl @@ -1,5 +1,6 @@ {{/* -service class: all services should adhere to this +This template serves as a blueprint for all Service objects that are created +within the common library. */}} {{- define "common.classes.service" -}} {{- $values := .Values.service -}} diff --git a/charts/common/templates/classes/_service_ports.tpl b/charts/common/templates/classes/_service_ports.tpl index 3508e1de..2c8f56d2 100644 --- a/charts/common/templates/classes/_service_ports.tpl +++ b/charts/common/templates/classes/_service_ports.tpl @@ -1,5 +1,5 @@ {{/* -logic that lists the ports and additionalPorts for a service +Render all the ports and additionalPorts for a Service object. */}} {{- define "common.classes.service.ports" -}} {{- $ports := list -}} @@ -12,9 +12,9 @@ logic that lists the ports and additionalPorts for a service ports: {{- range $_ := $ports }} - port: {{ .port }} - targetPort: {{ .targetPort | default .name }} + targetPort: {{ .targetPort | default "http" }} protocol: {{ .protocol | default "TCP" }} - name: {{ .name }} + name: {{ .name | default "http" }} {{- if (and (eq $.svcType "NodePort") (not (empty .nodePort))) }} nodePort: {{ .nodePort }} {{ end }} diff --git a/charts/common/templates/lib/chart/_capabilities.tpl b/charts/common/templates/lib/chart/_capabilities.tpl index 1aaf5044..05a8c6d7 100644 --- a/charts/common/templates/lib/chart/_capabilities.tpl +++ b/charts/common/templates/lib/chart/_capabilities.tpl @@ -1,5 +1,16 @@ {{/* -Return the appropriate apiVersion for deployment. +Return the appropriate apiVersion for DaemonSet objects. +*/}} +{{- define "common.capabilities.daemonset.apiVersion" -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "extensions/v1beta1" -}} +{{- else -}} +{{- print "apps/v1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for Deployment objects. */}} {{- define "common.capabilities.deployment.apiVersion" -}} {{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} @@ -10,7 +21,7 @@ Return the appropriate apiVersion for deployment. {{- end -}} {{/* -Return the appropriate apiVersion for statefulset. +Return the appropriate apiVersion for StatefulSet objects. */}} {{- define "common.capabilities.statefulset.apiVersion" -}} {{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} @@ -21,7 +32,7 @@ Return the appropriate apiVersion for statefulset. {{- end -}} {{/* -Return the appropriate apiVersion for ingress. +Return the appropriate apiVersion for Ingress objects. */}} {{- define "common.capabilities.ingress.apiVersion" -}} {{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/common/templates/lib/chart/_labels.tpl b/charts/common/templates/lib/chart/_labels.tpl index a5dda121..10981d9b 100644 --- a/charts/common/templates/lib/chart/_labels.tpl +++ b/charts/common/templates/lib/chart/_labels.tpl @@ -1,5 +1,5 @@ {{/* -Common labels +Common labels shared across objects. */}} {{- define "common.labels" -}} helm.sh/chart: {{ include "common.names.chart" . }} @@ -11,7 +11,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* -Selector labels +Selector labels shared across objects. */}} {{- define "common.labels.selectorLabels" -}} app.kubernetes.io/name: {{ include "common.names.name" . }} diff --git a/charts/common/templates/lib/chart/_names.tpl b/charts/common/templates/lib/chart/_names.tpl index 9f7cdf65..1dcd878a 100644 --- a/charts/common/templates/lib/chart/_names.tpl +++ b/charts/common/templates/lib/chart/_names.tpl @@ -31,12 +31,12 @@ Create chart name and version as used by the chart label. {{- end }} {{/* -Create the name of the service account to use +Create the name of the ServiceAccount to use. */}} {{- define "common.names.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "k8s-at-home.fullname" .) .Values.serviceAccount.name }} + {{- default (include "common.names.fullname" .) .Values.serviceAccount.name }} {{- else }} -{{- default "default" .Values.serviceAccount.name }} + {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} diff --git a/charts/common/templates/lib/chart/_values.tpl b/charts/common/templates/lib/chart/_values.tpl index e89eda1a..712202a0 100644 --- a/charts/common/templates/lib/chart/_values.tpl +++ b/charts/common/templates/lib/chart/_values.tpl @@ -1,5 +1,7 @@ +{{/* +Merge the local chart values and the common chart defaults. +*/}} {{- define "common.values.setup" -}} - {{- /* Merge the local chart values and the common chart defaults */ -}} {{- if .Values.common -}} {{- $defaultValues := deepCopy .Values.common -}} {{- $userValues := deepCopy (omit .Values "common") -}} diff --git a/charts/common/templates/lib/controller/_container.tpl b/charts/common/templates/lib/controller/_container.tpl index 671471e6..1f8bdaa9 100644 --- a/charts/common/templates/lib/controller/_container.tpl +++ b/charts/common/templates/lib/controller/_container.tpl @@ -1,8 +1,8 @@ {{- /* -The main containter that will be included in the controller +The main container included in the controller. */ -}} {{- define "common.controller.mainContainer" -}} -- name: {{ template "common.names.fullname" . }} +- name: {{ include "common.names.fullname" . }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} {{- with .Values.securityContext }} diff --git a/charts/common/templates/lib/controller/_ports.tpl b/charts/common/templates/lib/controller/_ports.tpl index ccf4b222..e80e7fd8 100644 --- a/charts/common/templates/lib/controller/_ports.tpl +++ b/charts/common/templates/lib/controller/_ports.tpl @@ -1,5 +1,5 @@ {{/* -ports included by the controller +Ports included by the controller. */}} {{- define "common.controller.ports" -}} {{- $ports := list -}} diff --git a/charts/common/templates/lib/controller/_probes.tpl b/charts/common/templates/lib/controller/_probes.tpl index 37996647..ef194ed5 100644 --- a/charts/common/templates/lib/controller/_probes.tpl +++ b/charts/common/templates/lib/controller/_probes.tpl @@ -1,5 +1,5 @@ {{/* -Default liveness/readiness/startup probes +Liveness/readiness/startup probes based on tcpSocket checks. */}} {{- define "common.controller.probes.tcpSocket" -}} {{- if .Values.probes.liveness.enabled -}} diff --git a/charts/common/templates/lib/controller/_volumes.tpl b/charts/common/templates/lib/controller/_volumes.tpl index 08f343b8..fccab6df 100644 --- a/charts/common/templates/lib/controller/_volumes.tpl +++ b/charts/common/templates/lib/controller/_volumes.tpl @@ -1,5 +1,5 @@ {{/* -volumes included by the controller +Volumes included by the controller. */}} {{- define "common.controller.volumes" -}} {{- range $index, $persistence := .Values.persistence }} diff --git a/charts/common/values.yaml b/charts/common/values.yaml index 1dd40022..b234c1ba 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -1,21 +1,36 @@ -# type: options are statefulset or deployment +# type: options are deployment, daemonset or statefulset controllerType: deployment -# Set annotations on the deployment/statefulset +# Set annotations on the deployment/statefulset/daemonset controllerAnnotations: {} -# Set labels on the deployment/statefulset +# Set labels on the deployment/statefulset/daemonset controllerLabels: {} replicas: 1 strategy: ## For Deployments, valid values are Recreate and RollingUpdate ## For StatefulSets, valid values are OnDelete and RollingUpdate + ## DaemonSets ignore this type: RollingUpdate # Set annotations on the pod podAnnotations: {} +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + env: {} +# When using hostNetwork make sure you set dnsPolicy to ClusterFirstWithHostNet +hostNetwork: false + +dnsPolicy: Default + initContainers: [] additionalContainers: [] @@ -44,9 +59,11 @@ service: # Specify the default port information port: port: - name: http + # name defaults to http + name: protocol: TCP - targetPort: http + # targetPort defaults to http + targetPort: ## Specify the nodePort value for the LoadBalancer and NodePort service types. ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport ## @@ -66,10 +83,12 @@ service: # type: ClusterIP # # Specify the default port information # port: - # port: "" - # name: http + # port: + # # name defaults to http + # name: # protocol: TCP - # targetPort: http + # # targetPort defaults to http + # targetPort: # # nodePort: # additionalPorts: [] # annotations: {} @@ -147,6 +166,14 @@ affinity: {} tolerations: [] +hostAliases: [] +# Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. +# ref: https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/ +# - ip: "192.168.1.100" +# hostnames: +# - "example.com" +# - "www.example.com" + addons: vpn: enabled: false