diff --git a/charts/manifests/Chart.yaml b/charts/manifests/Chart.yaml index 54c1332d..a3676113 100644 --- a/charts/manifests/Chart.yaml +++ b/charts/manifests/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: manifests description: "Bedag's Manifest chart. Library full of basic kubernetes manifests." type: library -version: 0.3.0 +version: 0.4.0 icon: "https://www.bedag.ch/wGlobal/wGlobal/layout/images/logo.svg" keywords: - Bedag diff --git a/charts/manifests/templates/manifests/README.md b/charts/manifests/templates/manifests/README.md index d5b77e9b..a1d1da2d 100644 --- a/charts/manifests/templates/manifests/README.md +++ b/charts/manifests/templates/manifests/README.md @@ -147,6 +147,7 @@ With the Manifest templates you have the possibility to get a single resource. T Currently we support the following Kubernetes Manifests: * **[Cronjob](#cronjob)** + * **[DaemonSet](#daemonset)** * **[Deployment](#deployment)** * **[HorizontalPodAutoscaler](#horizontalpodautoscaler)** * **[Ingress](#ingress)** @@ -201,6 +202,47 @@ resources: ... ``` +## DaemonSet + +This Template returns a [DaemonSet](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/) Kubernetes Manifest. + +### Arguments + +The following arguments are supported for this template. If a required argument is not given, the template will fail or return empty. + + * `.values` - Supported key structure for this manifest (See below). Will be merged over the default values for this manifest (Optional). + * `.overwrites` - Supported key structure overwriting the structure given to `.values` (Optional). + * `.name` - Partial name for the manifest, influences the result of the `bedag-lib.fullname` template (Optional). + * `.fullname` - Full name for the manifest, influences the result of the `bedag-lib.fullname` template (Optional). + * `.context` - Inherited Root Context (Required) + +### [Values](../values/manifests/daemonset.yaml) + +You can access the supported values for this kubernetes manifest through clicking on values. These values represent the default values for this manifest. + +### Templates + +Implements the following templates: + + * **[Pod Template](#pod-template)** + +### Usage + +``` +{{ include "bedag-lib.manifest.daemonset" (dict "values" $.Values.daemonset "fullname" "custom-daemonset" "context" $) }} +``` + +#### With Bundle + +``` +resources: + ... + - type: "daemonset" + values: {{ toYaml $.Values.daemonset | nindent 6 }} + fullname: "custom-daemonset" + ... +``` + ## Deployment This Template returns a [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) Kubernetes Manifest. diff --git a/charts/manifests/templates/manifests/_daemonset.tpl b/charts/manifests/templates/manifests/_daemonset.tpl new file mode 100644 index 00000000..ea75d37e --- /dev/null +++ b/charts/manifests/templates/manifests/_daemonset.tpl @@ -0,0 +1,50 @@ +{{/* +Copyright © 2020 Oliver Baehler + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*/}} +{{- define "bedag-lib.manifest.daemonset.values" -}} + {{- include "lib.utils.strings.template" (dict "value" (include "bedag-lib.utils.common.mergedValues" (dict "type" "daemonset" "root" .)) "context" .context) }} +{{- end }} + +{{- define "bedag-lib.manifest.daemonset" -}} + {{- if .context -}} + {{- $context := .context -}} + {{- $daemonset := (fromYaml (include "bedag-lib.manifest.daemonset.values" .)) -}} +kind: DaemonSet + {{- if $daemonset.apiVersion }} +apiVersion: {{ $daemonset.apiVersion }} + {{- else }} +apiVersion: apps/v1 + {{- end }} +metadata: + name: {{ include "bedag-lib.utils.common.fullname" . }} + labels: {{- include "lib.utils.common.labels" (dict "labels" $daemonset.labels "context" $context)| nindent 4 }} +spec: + minReadySeconds: {{ default 0 $daemonset.minReadySeconds }} + revisionHistoryLimit: {{ default 10 $daemonset.revisionHistoryLimit }} + selector: + matchLabels: {{- include "lib.utils.strings.template" (dict "value" (default (include "lib.utils.common.selectorLabels" $context) $daemonset.selectorLabels) "context" $context) | indent 6 }} + template: {{- include "bedag-lib.template.pod" (set . "pod" $daemonset) | nindent 4 }} + updateStrategy: + {{- $updateStrategy := (default "RollingUpdate" $daemonset.updateStrategy) }} + type: {{ $updateStrategy | quote }} + {{- if (eq "OnDelete" $updateStrategy) }} + rollingUpdate: null + {{- else if $daemonset.rollingUpdatemaxUnavailable }} + rollingUpdate: + maxUnavailable: {{ $daemonset.rollingUpdatemaxUnavailable }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/manifests/templates/manifests/templates/_bundleExtras.tpl b/charts/manifests/templates/manifests/templates/_bundleExtras.tpl index 3519dd26..7f65acc4 100644 --- a/charts/manifests/templates/manifests/templates/_bundleExtras.tpl +++ b/charts/manifests/templates/manifests/templates/_bundleExtras.tpl @@ -17,7 +17,7 @@ limitations under the License. */}} {{- define "bedag-lib.template.bundleExtras" -}} {{- if and .values .context }} - {{- if (has .type (list "deployment" "pod" "statefulset")) }} + {{- if (has .type (list "deployment" "pod" "statefulset" "daemonset")) }} {{- if .values.serviceAccount }} {{- if and .values.serviceAccount.enabled .values.serviceAccount.create }} ---{{- include "bedag-lib.manifest.serviceaccount" (dict "values" .values.serviceAccount "context" .context) | nindent 0 }} diff --git a/charts/manifests/templates/values/manifests/_daemonset.yaml b/charts/manifests/templates/values/manifests/_daemonset.yaml new file mode 100644 index 00000000..9013c9fb --- /dev/null +++ b/charts/manifests/templates/values/manifests/_daemonset.yaml @@ -0,0 +1,43 @@ +{{- define "bedag-lib.values.daemonset" -}} + {{- $context := (default $ .context) }} + {{- $_ := dict "parentKey" (default "daemonset" .key) "path" (cat (default "" (default $context.path .path)) (default "daemonset" .key) "." | nospace) "context" $context "data" (default dict .data) "minimal" (default false .minimal) }} +# +## - DaemonSet +## Reference: https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/ +## +{{ $_.parentKey }}: + + ## DaemonSet API version + # {{ $_.path }}apiVersion -- Configure the api version used for the DaemonSet resource + apiVersion: "" + + ## DaemonSet Labels + # {{ $_.path }}labels -- Merges given labels with common labels + labels: {} + + ## DaemonSet Selector Labels + # {{ $_.path }}selectorLabels -- Define SelectorLabels for the Pod Template + selectorLabels: {} + + ## DaemonSet minReadySeconds + # {{ $_.path }}minReadySeconds -- DaemonSet [Min Ready in Seconds](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#performing-a-rolling-update). **DaemonSet only** + minReadySeconds: "" + + ## DaemonSet, can be set to RollingUpdate or OnDelete by default. + # {{ $_.path }}updateStrategy -- DaemonSet [Update Strategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#performing-a-rolling-update). **DaemonSet only** + updateStrategy: RollingUpdate + + ## maxUnavailable update strategy + # {{ $_.path }}rollingUpdatePartition -- DaemonSet [Update Pratition](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#pod-management-policies). **DaemonSet only** + rollingUpdatemaxUnavailable: "" + + ## Pod Configuration + ## {{ include "bedag-lib.utils.intern.docLink" $_ }}#pod-template + {{- if $_.minimal }} + ## Supports all the values from the referenced template. Find all available values in the link above. + {{- else }} + ## Full Configuration + + {{- include "bedag-lib.values.template.pod" $_ | nindent 2 }} + {{- end }} +{{- end -}}