From d457326debdf3bd52b19ee3af9267cad5b64d88e Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Wed, 6 Mar 2024 13:36:18 +0100 Subject: [PATCH] [operator] Allow adding custom annotations to various objects Similar to `additionalLabels`, but for annotations. This is somewhat inspired by `cert-manager`s Helm chart [1], which allows custom annotations on essentially all Kubernetes objects. E.g. there could be internal annotations in certain environments that are recommended or required [1]: https://artifacthub.io/packages/helm/cert-manager/cert-manager --- .../templates/deployment.yaml | 4 +++ .../templates/service.yaml | 8 ++++++ .../opentelemetry-operator/values.schema.json | 27 +++++++++++++++++++ charts/opentelemetry-operator/values.yaml | 8 ++++++ 4 files changed, 47 insertions(+) diff --git a/charts/opentelemetry-operator/templates/deployment.yaml b/charts/opentelemetry-operator/templates/deployment.yaml index 59810330d..393593b0d 100644 --- a/charts/opentelemetry-operator/templates/deployment.yaml +++ b/charts/opentelemetry-operator/templates/deployment.yaml @@ -1,6 +1,10 @@ apiVersion: apps/v1 kind: Deployment metadata: + {{- with .Values.manager.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "opentelemetry-operator.labels" . | nindent 4 }} app.kubernetes.io/component: controller-manager diff --git a/charts/opentelemetry-operator/templates/service.yaml b/charts/opentelemetry-operator/templates/service.yaml index b523c35fe..d41b53aa7 100644 --- a/charts/opentelemetry-operator/templates/service.yaml +++ b/charts/opentelemetry-operator/templates/service.yaml @@ -1,6 +1,10 @@ apiVersion: v1 kind: Service metadata: + {{- with .Values.manager.serviceAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "opentelemetry-operator.labels" . | nindent 4 }} app.kubernetes.io/component: controller-manager @@ -27,6 +31,10 @@ spec: apiVersion: v1 kind: Service metadata: + {{- with .Values.admissionWebhooks.serviceAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} labels: {{- include "opentelemetry-operator.labels" . | nindent 4 }} app.kubernetes.io/component: controller-manager diff --git a/charts/opentelemetry-operator/values.schema.json b/charts/opentelemetry-operator/values.schema.json index 2d063d0a4..c5d6aff2b 100644 --- a/charts/opentelemetry-operator/values.schema.json +++ b/charts/opentelemetry-operator/values.schema.json @@ -111,6 +111,8 @@ "env", "serviceAccount", "serviceMonitor", + "deploymentAnnotations", + "serviceAnnotations", "podAnnotations", "podLabels", "prometheusRule", @@ -693,6 +695,22 @@ }] }] }, + "deploymentAnnotations": { + "type": "object", + "default": {}, + "title": "The deploymentAnnotations Schema", + "required": [], + "properties": {}, + "examples": [{}] + }, + "serviceAnnotations": { + "type": "object", + "default": {}, + "title": "The serviceAnnotations Schema", + "required": [], + "properties": {}, + "examples": [{}] + }, "podAnnotations": { "type": "object", "default": {}, @@ -1232,6 +1250,7 @@ "cert_file", "key_file", "ca_file", + "serviceAnnotations", "secretAnnotations", "secretLabels" ], @@ -1427,6 +1446,14 @@ "" ] }, + "serviceAnnotations": { + "type": "object", + "default": {}, + "title": "The serviceAnnotations Schema", + "required": [], + "properties": {}, + "examples": [{}] + }, "secretAnnotations": { "type": "object", "default": {}, diff --git a/charts/opentelemetry-operator/values.yaml b/charts/opentelemetry-operator/values.yaml index ce5f56212..96c1447fe 100644 --- a/charts/opentelemetry-operator/values.yaml +++ b/charts/opentelemetry-operator/values.yaml @@ -97,6 +97,11 @@ manager: metricsEndpoints: - port: metrics + # Adds additional annotations to the manager Deployment + deploymentAnnotations: {} + # Adds additional annotations to the manager Service + serviceAnnotations: {} + podAnnotations: {} podLabels: {} @@ -239,6 +244,9 @@ admissionWebhooks: ## Path to the CA cert. ca_file: "" + # Adds additional annotations to the admissionWebhook Service + serviceAnnotations: {} + ## Secret annotations secretAnnotations: {} ## Secret labels