From 2ef00ab18442bb44fc9c39f005a7f8571558a900 Mon Sep 17 00:00:00 2001 From: Luna Stadler Date: Wed, 6 Mar 2024 13:33:28 +0100 Subject: [PATCH] [operator] Add the ability to add `additionalLabels` This already existed in the `opentelemetry-collector` chart, now it is available in the `opentelemetry-operator` as well. These labels can be useful in environments where additional labels are recommended or required. --- .../operator-webhook-with-cert-manager.yaml | 2 ++ .../examples/default/rendered/certmanager.yaml | 2 ++ .../examples/default/rendered/clusterrole.yaml | 3 +++ .../examples/default/rendered/clusterrolebinding.yaml | 2 ++ .../examples/default/rendered/deployment.yaml | 1 + .../examples/default/rendered/role.yaml | 1 + .../examples/default/rendered/rolebinding.yaml | 1 + .../examples/default/rendered/service.yaml | 2 ++ .../examples/default/rendered/serviceaccount.yaml | 1 + .../rendered/tests/test-certmanager-connection.yaml | 1 + .../rendered/tests/test-service-connection.yaml | 2 ++ charts/opentelemetry-operator/templates/_helpers.tpl | 7 +++++++ charts/opentelemetry-operator/values.schema.json | 11 ++++++++++- charts/opentelemetry-operator/values.yaml | 3 +++ 14 files changed, 38 insertions(+), 1 deletion(-) diff --git a/charts/opentelemetry-operator/examples/default/rendered/admission-webhooks/operator-webhook-with-cert-manager.yaml b/charts/opentelemetry-operator/examples/default/rendered/admission-webhooks/operator-webhook-with-cert-manager.yaml index 0086f2d30..dae8ed7a0 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/admission-webhooks/operator-webhook-with-cert-manager.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/admission-webhooks/operator-webhook-with-cert-manager.yaml @@ -11,6 +11,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: webhook name: example-opentelemetry-operator-mutation webhooks: @@ -96,6 +97,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: webhook name: example-opentelemetry-operator-validation webhooks: diff --git a/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml b/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml index 600ed11b7..fb9e7401a 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: webhook name: example-opentelemetry-operator-serving-cert namespace: default @@ -34,6 +35,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: webhook name: example-opentelemetry-operator-selfsigned-issuer namespace: default diff --git a/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml b/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml index 987a1477d..dbeab8843 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-manager rules: @@ -218,6 +219,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-metrics rules: @@ -236,6 +238,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-proxy rules: diff --git a/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml b/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml index 8b9f1667d..71ba95ef7 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-manager roleRef: @@ -30,6 +31,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-proxy roleRef: diff --git a/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml b/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml index 583f4956d..48a766a6b 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator namespace: default diff --git a/charts/opentelemetry-operator/examples/default/rendered/role.yaml b/charts/opentelemetry-operator/examples/default/rendered/role.yaml index 7a3dc0dd8..d23b455bc 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/role.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/role.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-leader-election namespace: default diff --git a/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml b/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml index fccdd1c18..21848e27c 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-leader-election namespace: default diff --git a/charts/opentelemetry-operator/examples/default/rendered/service.yaml b/charts/opentelemetry-operator/examples/default/rendered/service.yaml index a7d95887d..c002f71bc 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/service.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/service.yaml @@ -9,6 +9,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator namespace: default @@ -36,6 +37,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager name: example-opentelemetry-operator-webhook namespace: default diff --git a/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml b/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml index 7d47d4d91..9e671eb05 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml @@ -11,4 +11,5 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager diff --git a/charts/opentelemetry-operator/examples/default/rendered/tests/test-certmanager-connection.yaml b/charts/opentelemetry-operator/examples/default/rendered/tests/test-certmanager-connection.yaml index adb838631..ae1112669 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/tests/test-certmanager-connection.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/tests/test-certmanager-connection.yaml @@ -11,6 +11,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: webhook annotations: "helm.sh/hook": test diff --git a/charts/opentelemetry-operator/examples/default/rendered/tests/test-service-connection.yaml b/charts/opentelemetry-operator/examples/default/rendered/tests/test-service-connection.yaml index e5972e670..8b035c8f4 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/tests/test-service-connection.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/tests/test-service-connection.yaml @@ -11,6 +11,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager annotations: "helm.sh/hook": test @@ -48,6 +49,7 @@ metadata: app.kubernetes.io/version: "0.95.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: example + app.kubernetes.io/component: controller-manager annotations: "helm.sh/hook": test diff --git a/charts/opentelemetry-operator/templates/_helpers.tpl b/charts/opentelemetry-operator/templates/_helpers.tpl index 8e84476cf..f78b0d8b3 100644 --- a/charts/opentelemetry-operator/templates/_helpers.tpl +++ b/charts/opentelemetry-operator/templates/_helpers.tpl @@ -41,6 +41,7 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} +{{ include "opentelemetry-operator.additionalLabels" . }} {{- end }} {{/* @@ -73,6 +74,12 @@ Create the name of the service account to use {{- end }} {{- end }} +{{- define "opentelemetry-operator.additionalLabels" -}} +{{- if .Values.additionalLabels }} +{{- tpl (.Values.additionalLabels | toYaml) . }} +{{- end }} +{{- end }} + {{/* Create an ordered name of the MutatingWebhookConfiguration */}} diff --git a/charts/opentelemetry-operator/values.schema.json b/charts/opentelemetry-operator/values.schema.json index 4473ad6ac..2d063d0a4 100644 --- a/charts/opentelemetry-operator/values.schema.json +++ b/charts/opentelemetry-operator/values.schema.json @@ -21,7 +21,8 @@ "hostNetwork", "priorityClassName", "securityContext", - "testFramework" + "testFramework", + "additionalLabels" ], "properties": { "replicaCount": { @@ -1660,6 +1661,14 @@ "tag": "latest" } }] + }, + "additionalLabels": { + "type": "object", + "default": {}, + "title": "The additionalLabels Schema", + "required": [], + "properties": {}, + "examples": [{}] } }, "examples": [{ diff --git a/charts/opentelemetry-operator/values.yaml b/charts/opentelemetry-operator/values.yaml index bf60024a0..ce5f56212 100644 --- a/charts/opentelemetry-operator/values.yaml +++ b/charts/opentelemetry-operator/values.yaml @@ -11,6 +11,9 @@ nameOverride: "" ## Reference one or more secrets to be used when pulling images from authenticated repositories. imagePullSecrets: [] +# Common labels to add to all otel-collector resources. Evaluated as a template. +additionalLabels: {} + ## Pod Disruption Budget configuration ## pdb: