From 073c1eeb8f826c88553d5b8c07690c9c7032b7eb Mon Sep 17 00:00:00 2001 From: Anthony Hausman Date: Fri, 21 Aug 2026 17:40:38 +0200 Subject: [PATCH] feat(helm): add deploymentAnnotations and podDisruptionBudget Support custom deployment metadata annotations and configurable PodDisruptionBudget for kagent-tools. Assisted-by: Gemini 3.7 Flash Signed-off-by: Anthony Hausman --- helm/kagent-tools/templates/deployment.yaml | 4 ++ helm/kagent-tools/templates/pdb.yaml | 29 ++++++++++ helm/kagent-tools/tests/deployment_test.yaml | 21 +++++++ helm/kagent-tools/tests/pdb_test.yaml | 59 ++++++++++++++++++++ helm/kagent-tools/values.yaml | 12 ++++ 5 files changed, 125 insertions(+) create mode 100644 helm/kagent-tools/templates/pdb.yaml create mode 100644 helm/kagent-tools/tests/pdb_test.yaml diff --git a/helm/kagent-tools/templates/deployment.yaml b/helm/kagent-tools/templates/deployment.yaml index c92c9c6..19e1e10 100644 --- a/helm/kagent-tools/templates/deployment.yaml +++ b/helm/kagent-tools/templates/deployment.yaml @@ -5,6 +5,10 @@ metadata: namespace: {{ include "kagent-tools.namespace" . }} labels: {{- include "kagent-tools.labels" . | nindent 4 }} + {{- with .Values.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} spec: replicas: {{ .Values.replicaCount }} selector: diff --git a/helm/kagent-tools/templates/pdb.yaml b/helm/kagent-tools/templates/pdb.yaml new file mode 100644 index 0000000..6cb9183 --- /dev/null +++ b/helm/kagent-tools/templates/pdb.yaml @@ -0,0 +1,29 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "kagent-tools.fullname" . }} + namespace: {{ include "kagent-tools.namespace" . }} + labels: + {{- include "kagent-tools.labels" . | nindent 4 }} + {{- with .Values.podDisruptionBudget.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.podDisruptionBudget.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} + {{- end }} + {{- if .Values.podDisruptionBudget.unhealthyPodEvictionPolicy }} + unhealthyPodEvictionPolicy: {{ .Values.podDisruptionBudget.unhealthyPodEvictionPolicy }} + {{- end }} + selector: + matchLabels: + {{- include "kagent-tools.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/helm/kagent-tools/tests/deployment_test.yaml b/helm/kagent-tools/tests/deployment_test.yaml index 84bdaae..847a65d 100644 --- a/helm/kagent-tools/tests/deployment_test.yaml +++ b/helm/kagent-tools/tests/deployment_test.yaml @@ -173,3 +173,24 @@ tests: value: app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME + + - it: should not have deployment annotations by default + template: deployment.yaml + asserts: + - isNull: + path: metadata.annotations + + - it: should render custom deployment annotations + template: deployment.yaml + set: + deploymentAnnotations: + keel.sh/policy: "force" + example.com/annotation: "test-value" + asserts: + - equal: + path: metadata.annotations["keel.sh/policy"] + value: "force" + - equal: + path: metadata.annotations["example.com/annotation"] + value: "test-value" + diff --git a/helm/kagent-tools/tests/pdb_test.yaml b/helm/kagent-tools/tests/pdb_test.yaml new file mode 100644 index 0000000..f8e15e1 --- /dev/null +++ b/helm/kagent-tools/tests/pdb_test.yaml @@ -0,0 +1,59 @@ +suite: test pod disruption budget +templates: + - pdb.yaml +tests: + - it: should not render pdb by default + template: pdb.yaml + asserts: + - hasDocuments: + count: 0 + + - it: should render pdb when enabled with minAvailable + template: pdb.yaml + set: + podDisruptionBudget: + enabled: true + minAvailable: 1 + asserts: + - isKind: + of: PodDisruptionBudget + - equal: + path: metadata.name + value: RELEASE-NAME + - equal: + path: spec.minAvailable + value: 1 + - isNull: + path: spec.maxUnavailable + - equal: + path: spec.selector.matchLabels + value: + app.kubernetes.io/name: RELEASE-NAME + app.kubernetes.io/instance: RELEASE-NAME + + - it: should render pdb with maxUnavailable and annotations/labels + template: pdb.yaml + set: + podDisruptionBudget: + enabled: true + maxUnavailable: "50%" + unhealthyPodEvictionPolicy: IfHealthyBudget + labels: + custom-label: pdb-label + annotations: + custom-annotation: pdb-annotation + asserts: + - isKind: + of: PodDisruptionBudget + - equal: + path: spec.maxUnavailable + value: "50%" + - equal: + path: spec.unhealthyPodEvictionPolicy + value: IfHealthyBudget + - equal: + path: metadata.labels["custom-label"] + value: pdb-label + - equal: + path: metadata.annotations["custom-annotation"] + value: pdb-annotation diff --git a/helm/kagent-tools/values.yaml b/helm/kagent-tools/values.yaml index b398a00..ab10255 100644 --- a/helm/kagent-tools/values.yaml +++ b/helm/kagent-tools/values.yaml @@ -64,6 +64,9 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +# Annotations to add to the deployment +deploymentAnnotations: {} + podAnnotations: {} podSecurityContext: {} @@ -76,6 +79,15 @@ securityContext: {} # readOnlyRootFilesystem: true # runAsNonRoot: true # runAsUser: 1000 + +# PodDisruptionBudget configuration +podDisruptionBudget: + enabled: false + # minAvailable: 1 + # maxUnavailable: 1 + # labels: {} + # annotations: {} + # unhealthyPodEvictionPolicy: IfHealthyBudget # Node taints which will be tolerated for Pod. tolerations: []