diff --git a/examples/chart/event-handler/templates/configmap.yaml b/examples/chart/event-handler/templates/configmap.yaml index f2602c579eeaa..61088506b74c2 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 4707d17cfd1f1..daacc2770f114 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 1fadebfcca8aa..0cee7fb7de7fe 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: 18.5.1 + helm.sh/chart: teleport-plugin-event-handler-18.5.1 spec: containers: - command: diff --git a/examples/chart/event-handler/tests/configmap_test.yaml b/examples/chart/event-handler/tests/configmap_test.yaml index 2142f7f2cc6f1..ac75366924edf 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 aa5103c328e58..19d10fc141d6b 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 aa414c8c8061d..74da8d01986c9 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 787d22ca5ef02..dc3cb12d87151 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: {}