Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions charts/common/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: common
description: "Bedag's common Helm chart to use for creating other Helm charts"
version: 12.6.0
version: 12.7.0
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
Expand All @@ -27,5 +27,4 @@ annotations:
artifacthub.io/prerelease: "false"
artifacthub.io/license: Apache-2.0
artifacthub.io/changes: |
- "[Changed]: extra annotations and labels support sprig statements"
- "[Added]: Possibility to optionally set appVersion in values"
- "[Added]: PodDisruptionBudget (PDB) support for components"
8 changes: 7 additions & 1 deletion charts/common/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# common

![Version: 12.6.0](https://img.shields.io/badge/Version-12.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 12.7.0](https://img.shields.io/badge/Version-12.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

Bedag's common Helm chart to use for creating other Helm charts

Expand Down Expand Up @@ -67,3 +67,9 @@ Major Changes to functions are documented with the version affected. **Before up
| servicemonitor.basicAuth.userKey | string | `"username"` | userKey is the default key to grab the username in the secret |
| servicemonitor.deploy | bool | `false` | deploy has to be set to true for rendering to be applied |
| servicemonitor.endpoints | object | `{}` | |

## PodDisruptionBudget

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| components.component-1.pdbs | object | `{}` | pdbs is a dictionary of Pod Disruption Budgets to be configured for the component |
9 changes: 9 additions & 0 deletions charts/common/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ Major Changes to functions are documented with the version affected. **Before up
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}

## PodDisruptionBudget

{{ template "table.heading" . }}
{{- range .Values }}
{{- if and (hasPrefix "components.component-1.pdbs" .Key) }}
| {{ .Key }} | {{ .Type }} | {{ if .Default }}{{ .Default }}{{ else }}{{ .AutoDefault }}{{ end }} | {{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }} |
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/common/ci/values.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ includes:
pvcs: true
job: true
cronjob: true
pdb: true

# start common.ingress
ingress:
Expand Down Expand Up @@ -77,6 +78,14 @@ components:
kubernetes.io/metadata.name: namespace-1

# end common.networkpolicy

# start common.pdb
pdbs:
pdb-1:
deploy: true
minAvailable: 1
# end common.pdb

controller:
deploy: true
type: "Deployment"
Expand Down Expand Up @@ -185,6 +194,14 @@ components:
ipBlock:
cidr: 0.0.0.0/0
# end common.networkpolicy

# start common.pdb
pdbs:
pdb-1:
deploy: true
maxUnavailable: "50%"
# end common.pdb

controller:
deploy: true
type: "StatefulSet"
Expand Down
40 changes: 40 additions & 0 deletions charts/common/templates/_pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- define "common.pdb" -}}
{{- $root := . }}
{{- range $componentname, $component := .Values.components }}
{{- if $component.pdbs }}
{{- range $pdbname, $pdb := $component.pdbs }}
{{- if $pdb.deploy }}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ template "library.name" $root }}-{{ $componentname }}-{{ $pdbname }}
labels:
{{ include "library.labels.standard" $root | indent 4 }}
app.kubernetes.io/component: {{ $componentname }}
spec:
{{- if $pdb.minAvailable }}
minAvailable: {{ $pdb.minAvailable }}
{{- end }}
{{- if $pdb.maxUnavailable }}
maxUnavailable: {{ $pdb.maxUnavailable }}
{{- end }}
{{- if $pdb.unhealthyPodEvictionPolicy }}
unhealthyPodEvictionPolicy: {{ $pdb.unhealthyPodEvictionPolicy }}
{{- end }}
selector:
matchLabels:
{{- if not $pdb.overrideSelectors }}
app.kubernetes.io/name: {{ template "library.name" $root }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
app.kubernetes.io/component: {{ $componentname }}
{{- else }}
{{- range $key, $val := $pdb.overrideSelectors }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
4 changes: 4 additions & 0 deletions charts/common/templates/includes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@
{{- if .Values.includes.networkpolicy }}
{{- template "common.networkpolicy" . }}
{{- end -}}

{{- if .Values.includes.pdb }}
{{- template "common.pdb" . }}
{{- end -}}
25 changes: 25 additions & 0 deletions charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ includes:
pvcs: false
servicemonitor: false
networkpolicy: false
pdb: false

# timezone to set as environment variable 'TZ' in each pod. Comment out for using default ("Europe/Zurich")
# timezone: "Europe/Zurich"
Expand Down Expand Up @@ -303,6 +304,30 @@ components:
# port: 8081
# end common.networkpolicy

# start common.pdb
# -- pdbs is a dictionary of Pod Disruption Budgets to be configured for the component
pdbs: {}
# specify the name of the pdb
# pdb-1:
# -- deploy has to be set to true for rendering to be applied
# deploy: false
# -- minAvailable specifies the minimum number of pods that must be available during a disruption.
# Can be an absolute number (e.g. 1) or a percentage (e.g. "50%").
# Either minAvailable or maxUnavailable must be set, but not both.
# minAvailable: 1
# -- maxUnavailable specifies the maximum number of pods that can be unavailable during a disruption.
# Can be an absolute number (e.g. 1) or a percentage (e.g. "50%").
# Either minAvailable or maxUnavailable must be set, but not both.
# maxUnavailable: 1
# -- unhealthyPodEvictionPolicy defines the criteria for when unhealthy pods should be considered for eviction.
# Valid values are "IfHealthyBudget" and "AlwaysAllow". Default behavior if not set depends on the Kubernetes version.
# unhealthyPodEvictionPolicy: "IfHealthyBudget"
# -- overrideSelectors is optional for overriding the default labels: 'app.kubernetes.io/name', 'app.kubernetes.io/instance' & 'app.kubernetes.io/component'
# overrideSelectors:
# label1: "value1"
# label2: "value2"
# end common.pdb

# controller is used for deploying pods via Deployment, StatefulSet, Job or CronJob ressources
controller:
# deploy has to be set to true for rendering to be applied
Expand Down
Loading