From 05f13a77cca97f889aeefb674ede34bf7f87aea0 Mon Sep 17 00:00:00 2001 From: Kevin <76608931+kshi36@users.noreply.github.com> Date: Thu, 11 Dec 2025 16:00:55 -0800 Subject: [PATCH] Add `annotations` support for Event Handler helm chart (#62081) * Add configmap and deployment annotations for event handler helm chart * Update documentation for podAnnotations --- .../event-handler/templates/configmap.yaml | 4 ++ .../event-handler/templates/deployment.yaml | 8 ++- .../__snapshot__/deployment_test.yaml.snap | 3 + .../event-handler/tests/configmap_test.yaml | 18 ++++++ .../event-handler/tests/deployment_test.yaml | 59 +++++++++++++++++++ .../chart/event-handler/values.schema.json | 27 +++++++++ examples/chart/event-handler/values.yaml | 13 ++++ 7 files changed, 130 insertions(+), 2 deletions(-) diff --git a/examples/chart/event-handler/templates/configmap.yaml b/examples/chart/event-handler/templates/configmap.yaml index f2602c579ee..61088506b74 100644 --- a/examples/chart/event-handler/templates/configmap.yaml +++ b/examples/chart/event-handler/templates/configmap.yaml @@ -2,6 +2,10 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "event-handler.fullname" . }} + {{- with .Values.annotations.config }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "event-handler.labels" . | nindent 4 }} data: diff --git a/examples/chart/event-handler/templates/deployment.yaml b/examples/chart/event-handler/templates/deployment.yaml index 4707d17cfd1..daacc2770f1 100644 --- a/examples/chart/event-handler/templates/deployment.yaml +++ b/examples/chart/event-handler/templates/deployment.yaml @@ -2,6 +2,10 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "event-handler.fullname" . }} + {{- with .Values.annotations.deployment }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "event-handler.labels" . | nindent 4 }} spec: @@ -15,12 +19,12 @@ spec: {{- include "event-handler.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} + {{- with coalesce .Values.annotations.pod .Values.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "event-handler.selectorLabels" . | nindent 8 }} + {{- include "event-handler.labels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/examples/chart/event-handler/tests/__snapshot__/deployment_test.yaml.snap b/examples/chart/event-handler/tests/__snapshot__/deployment_test.yaml.snap index a81e8c1a0c9..ae903397543 100644 --- a/examples/chart/event-handler/tests/__snapshot__/deployment_test.yaml.snap +++ b/examples/chart/event-handler/tests/__snapshot__/deployment_test.yaml.snap @@ -20,7 +20,10 @@ should match the snapshot: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: teleport-plugin-event-handler + app.kubernetes.io/version: 19.0.0-dev + helm.sh/chart: teleport-plugin-event-handler-19.0.0-dev spec: containers: - command: diff --git a/examples/chart/event-handler/tests/configmap_test.yaml b/examples/chart/event-handler/tests/configmap_test.yaml index 2142f7f2cc6..ac75366924e 100644 --- a/examples/chart/event-handler/tests/configmap_test.yaml +++ b/examples/chart/event-handler/tests/configmap_test.yaml @@ -16,3 +16,21 @@ tests: keyPath: myclient.key asserts: - matchSnapshot: {} + + - it: should not contain annotations when not defined + asserts: + - isNull: + path: metadata.annotations + + - it: should contain annotations when defined + set: + annotations: + config: + keyA: valA + keyB: valB + asserts: + - equal: + path: metadata.annotations + value: + keyA: valA + keyB: valB diff --git a/examples/chart/event-handler/tests/deployment_test.yaml b/examples/chart/event-handler/tests/deployment_test.yaml index aa5103c328e..19d10fc141d 100644 --- a/examples/chart/event-handler/tests/deployment_test.yaml +++ b/examples/chart/event-handler/tests/deployment_test.yaml @@ -18,6 +18,7 @@ tests: - equal: path: spec.strategy.type value: Recreate + - it: should mount tls.existingCASecretName and set environment when set in values template: deployment.yaml values: @@ -42,3 +43,61 @@ tests: value: /etc/teleport-tls-ca/ca.pem - matchSnapshot: path: spec.template.spec + + - it: should not contain deployment or pod annotations when not defined + asserts: + - isNull: + path: metadata.annotations + - isNull: + path: spec.template.metadata.annotations + + - it: should contain deployment annotations when defined + set: + annotations: + deployment: + keyA: valA + keyB: valB + asserts: + - equal: + path: metadata.annotations + value: + keyA: valA + keyB: valB + - isNull: + path: spec.template.metadata.annotations + + - it: should contain pod annotations when defined + set: + annotations: + pod: + keyA: valA + keyB: valB + asserts: + - equal: + path: spec.template.metadata.annotations + value: + keyA: valA + keyB: valB + - isNull: + path: metadata.annotations + + - it: should contain both annotations when defined + set: + annotations: + deployment: + keyA: valA + keyB: valB + pod: + keyA: valA' + keyC: valC + asserts: + - equal: + path: metadata.annotations + value: + keyA: valA + keyB: valB + - equal: + path: spec.template.metadata.annotations + value: + keyA: valA' + keyC: valC diff --git a/examples/chart/event-handler/values.schema.json b/examples/chart/event-handler/values.schema.json index aa414c8c806..74da8d01986 100644 --- a/examples/chart/event-handler/values.schema.json +++ b/examples/chart/event-handler/values.schema.json @@ -11,6 +11,7 @@ "podSecurityContext", "securityContext", "nodeSelector", + "annotations", "tolerations", "affinity", "teleport", @@ -225,6 +226,32 @@ "default": {}, "additionalProperties": true }, + "annotations": { + "$id": "#/properties/annotations", + "type": "object", + "required": [ + "config", + "deployment", + "pod" + ], + "properties": { + "config": { + "$id": "#/properties/annotations/properties/config", + "type": "object", + "default": {} + }, + "deployment": { + "$id": "#/properties/annotations/properties/deployment", + "type": "object", + "default": {} + }, + "pod": { + "$id": "#/properties/annotations/properties/pod", + "type": "object", + "default": {} + } + } + }, "tls": { "$id": "#/properties/tls", "type": "object", diff --git a/examples/chart/event-handler/values.yaml b/examples/chart/event-handler/values.yaml index 787d22ca5ef..dc3cb12d871 100644 --- a/examples/chart/event-handler/values.yaml +++ b/examples/chart/event-handler/values.yaml @@ -128,6 +128,18 @@ persistentVolumeClaim: existingClaim: "" volumeName: "storage" +# annotations -- contains annotations to apply to the different Kubernetes +# objects created by the chart. See [the Kubernetes annotation +# documentation](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) +# for more details. +annotations: + # annotations.config(object) -- are annotations to set on the ConfigMap. + config: {} + # annotations.deployment(object) -- are annotations to set on the Deployment. + deployment: {} + # annotations.pod(object) -- are annotations to set on the Pods. + pod: {} + # # Deployment # @@ -141,6 +153,7 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +# Deprecated way to set pod annotations. `annotations.pod` should be preferred. podAnnotations: {} podSecurityContext: {}