Skip to content

Commit

Permalink
Merge pull request #17 from chifu1234/master
Browse files Browse the repository at this point in the history
[manifests] #15 Adding daemonset Manifest
  • Loading branch information
oliverbaehler authored Jan 11, 2021
2 parents 5919c96 + 169fab0 commit 982d1b8
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/manifests/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions charts/manifests/templates/manifests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand Down Expand Up @@ -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.
Expand Down
50 changes: 50 additions & 0 deletions charts/manifests/templates/manifests/_daemonset.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
43 changes: 43 additions & 0 deletions charts/manifests/templates/values/manifests/_daemonset.yaml
Original file line number Diff line number Diff line change
@@ -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 -}}

0 comments on commit 982d1b8

Please sign in to comment.