diff --git a/.changeset/expose-hyperdx-deployment-annotations.md b/.changeset/expose-hyperdx-deployment-annotations.md new file mode 100644 index 0000000..afc63b6 --- /dev/null +++ b/.changeset/expose-hyperdx-deployment-annotations.md @@ -0,0 +1,5 @@ +--- +"helm-charts": minor +--- + +Add explicit `hyperdx.deployment.deploymentAnnotations` and `hyperdx.deployment.podAnnotations` values while preserving `hyperdx.deployment.annotations` as a deprecated pod annotation alias. When both pod annotation values contain the same key, `podAnnotations` takes precedence. diff --git a/charts/clickstack/templates/hyperdx/deployment.yaml b/charts/clickstack/templates/hyperdx/deployment.yaml index 0719d07..7bfc9ec 100644 --- a/charts/clickstack/templates/hyperdx/deployment.yaml +++ b/charts/clickstack/templates/hyperdx/deployment.yaml @@ -1,7 +1,12 @@ +{{- $podAnnotations := mergeOverwrite (dict) (default (dict) .Values.hyperdx.deployment.annotations) (default (dict) .Values.hyperdx.deployment.podAnnotations) -}} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "clickstack.hyperdx.fullname" . }} + {{- with .Values.hyperdx.deployment.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "clickstack.labels" . | nindent 4 }} app: {{ include "clickstack.fullname" . }} @@ -24,8 +29,8 @@ spec: {{- include "clickstack.selectorLabels" . | nindent 8 }} app: {{ include "clickstack.fullname" . }} annotations: - {{- if .Values.hyperdx.deployment.annotations }} - {{- with .Values.hyperdx.deployment.annotations }} + {{- if $podAnnotations }} + {{- with $podAnnotations }} {{- toYaml . | nindent 8 }} {{- end -}} {{- end }} diff --git a/charts/clickstack/tests/hyperdx-deployment_test.yaml b/charts/clickstack/tests/hyperdx-deployment_test.yaml index 3c486e7..739eee0 100644 --- a/charts/clickstack/tests/hyperdx-deployment_test.yaml +++ b/charts/clickstack/tests/hyperdx-deployment_test.yaml @@ -6,6 +6,8 @@ tests: asserts: - isKind: of: Deployment + - isNull: + path: metadata.annotations - equal: path: spec.replicas value: 1 @@ -42,7 +44,7 @@ tests: path: spec.replicas value: 3 - - it: should add custom annotations when provided + - it: should preserve the deprecated annotations alias for pod annotations set: hyperdx: deployment: @@ -55,6 +57,52 @@ tests: content: prometheus.io/scrape: "true" prometheus.io/port: "3000" + + - it: should add custom pod annotations when podAnnotations is provided + set: + hyperdx: + deployment: + podAnnotations: + example.com/pod: "enabled" + asserts: + - isSubset: + path: spec.template.metadata.annotations + content: + example.com/pod: "enabled" + + - it: should keep deployment and pod annotations separate + set: + hyperdx: + deployment: + deploymentAnnotations: + example.com/configuration: deployment + podAnnotations: + example.com/configuration: pod + asserts: + - isSubset: + path: metadata.annotations + content: + example.com/configuration: deployment + - isSubset: + path: spec.template.metadata.annotations + content: + example.com/configuration: pod + + - it: should prefer podAnnotations over the deprecated annotations alias + set: + hyperdx: + deployment: + annotations: + example.com/configuration: legacy + example.com/legacy: preserved + podAnnotations: + example.com/configuration: explicit + asserts: + - isSubset: + path: spec.template.metadata.annotations + content: + example.com/configuration: explicit + example.com/legacy: preserved - it: should add custom labels when provided set: diff --git a/charts/clickstack/values.yaml b/charts/clickstack/values.yaml index 501eb82..337bcf4 100644 --- a/charts/clickstack/values.yaml +++ b/charts/clickstack/values.yaml @@ -107,6 +107,12 @@ hyperdx: tolerations: [] topologySpreadConstraints: [] priorityClassName: "" + # Annotations applied to the HyperDX Deployment metadata. + deploymentAnnotations: {} + # Annotations applied to the HyperDX pod template metadata. + podAnnotations: {} + # Deprecated: use podAnnotations. Retained for backward compatibility; + # podAnnotations takes precedence when both maps contain the same key. annotations: {} labels: {} env: []