Skip to content

Commit c7a50b1

Browse files
authored
feat: add configurable PodDisruptionBudget for core deployment (#953)
1 parent fdf4abc commit c7a50b1

5 files changed

Lines changed: 86 additions & 0 deletions

File tree

helm/flowfuse/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ For other values please refer to the documentation below.
6767
- `forge.revisionHistoryLimit` global default for number of old ReplicaSets/ControllerRevisions to retain for rollback across all Deployments and StatefulSets managed by this chart (default `10`). Can be overridden per component.
6868
- `forge.tolerations` allows to configure [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) for the core application deployment (default `[]`)
6969
- `forge.priorityClassName` allows to set [priorityClassName](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/) for all deployments created by this Helm chart (default not set)
70+
- `forge.podDisruptionBudget.enabled` enables a [PodDisruptionBudget](https://kubernetes.io/docs/tasks/run-application/configure-pdb/) for the core application deployment (default `false`)
71+
- `forge.podDisruptionBudget.minAvailable` minimum number/percentage of pods that must remain available during voluntary disruption (default `1`). Mutually exclusive with `maxUnavailable`.
72+
- `forge.podDisruptionBudget.maxUnavailable` maximum number/percentage of pods unavailable during voluntary disruption (default not set). Mutually exclusive with `minAvailable`.
7073
- `forge.service.type` allows to set the service type for the core application service (default `ClusterIP`)
7174
- `forge.service.nodePort` allows to set custom nodePort value when `forge.service.type` value is set to `NodePort` (default not set)
7275
- `forge.logging.level` sets logging level for the Forge app (default: `info` from "info", "error", "debug", "warn", "trace", "fatal")

helm/flowfuse/templates/pdb.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.forge.podDisruptionBudget.enabled }}
2+
apiVersion: policy/v1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: flowfuse
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "forge.labels" . | nindent 4 }}
9+
{{- with .Values.forge.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- if .Values.forge.podDisruptionBudget.minAvailable }}
14+
minAvailable: {{ .Values.forge.podDisruptionBudget.minAvailable }}
15+
{{- end }}
16+
{{- if .Values.forge.podDisruptionBudget.maxUnavailable }}
17+
maxUnavailable: {{ .Values.forge.podDisruptionBudget.maxUnavailable }}
18+
{{- end }}
19+
selector:
20+
matchLabels:
21+
{{- include "forge.forgeSelectorLabels" . | nindent 6 }}
22+
{{- end }}

helm/flowfuse/tests/pdb_test.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
2+
suite: test forge PodDisruptionBudget
3+
templates:
4+
- pdb.yaml
5+
set:
6+
forge.domain: "chart-unit-tests.com"
7+
tests:
8+
- it: should not render PDB by default
9+
asserts:
10+
- hasDocuments:
11+
count: 0
12+
13+
- it: should render PDB when enabled with minAvailable
14+
set:
15+
forge.podDisruptionBudget.enabled: true
16+
asserts:
17+
- isKind:
18+
of: PodDisruptionBudget
19+
- equal:
20+
path: metadata.name
21+
value: flowfuse
22+
- equal:
23+
path: spec.minAvailable
24+
value: 1
25+
- notExists:
26+
path: spec.maxUnavailable
27+
- equal:
28+
path: spec.selector.matchLabels.app
29+
value: flowforge
30+
31+
- it: should render maxUnavailable when set
32+
set:
33+
forge.podDisruptionBudget:
34+
enabled: true
35+
minAvailable: null
36+
maxUnavailable: 1
37+
asserts:
38+
- equal:
39+
path: spec.maxUnavailable
40+
value: 1
41+
- notExists:
42+
path: spec.minAvailable

helm/flowfuse/values.schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,20 @@
839839
"tolerations": {
840840
"type": "array"
841841
},
842+
"podDisruptionBudget": {
843+
"type": "object",
844+
"properties": {
845+
"enabled": {
846+
"type": "boolean"
847+
},
848+
"minAvailable": {
849+
"type": ["integer", "string"]
850+
},
851+
"maxUnavailable": {
852+
"type": ["integer", "string"]
853+
}
854+
}
855+
},
842856
"logPassthrough": {
843857
"type": "boolean"
844858
},

helm/flowfuse/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ forge:
135135

136136
priorityClassName: ""
137137

138+
podDisruptionBudget:
139+
enabled: false
140+
minAvailable: 1
141+
# maxUnavailable: 1 # set instead of minAvailable (mutually exclusive)
142+
138143
logPassthrough: false
139144
customHostname:
140145
enabled: false

0 commit comments

Comments
 (0)