From 90f3433ecf4b22e10715387a38b9345c8dbaf5a1 Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Sat, 6 Jan 2024 06:19:49 +0800 Subject: [PATCH] polish otel operator WebhookCert logical (#986) --- charts/opentelemetry-operator/Chart.yaml | 2 +- .../operator-webhook-with-cert-manager.yaml | 4 ++-- .../examples/default/rendered/certmanager.yaml | 4 ++-- .../examples/default/rendered/clusterrole.yaml | 6 +++--- .../examples/default/rendered/clusterrolebinding.yaml | 4 ++-- .../examples/default/rendered/deployment.yaml | 2 +- .../examples/default/rendered/role.yaml | 2 +- .../examples/default/rendered/rolebinding.yaml | 2 +- .../examples/default/rendered/service.yaml | 4 ++-- .../examples/default/rendered/serviceaccount.yaml | 2 +- .../default/rendered/tests/test-certmanager-connection.yaml | 2 +- .../default/rendered/tests/test-service-connection.yaml | 4 ++-- charts/opentelemetry-operator/templates/_helpers.tpl | 2 ++ 13 files changed, 21 insertions(+), 19 deletions(-) diff --git a/charts/opentelemetry-operator/Chart.yaml b/charts/opentelemetry-operator/Chart.yaml index 3c7abb379..3d28a2380 100644 --- a/charts/opentelemetry-operator/Chart.yaml +++ b/charts/opentelemetry-operator/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: opentelemetry-operator -version: 0.44.2 +version: 0.44.3 description: OpenTelemetry Operator Helm chart for Kubernetes type: application home: https://opentelemetry.io/ 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 1c176c36c..ea530cb2a 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 @@ -6,7 +6,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -91,7 +91,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml b/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml index f1ea39778..b1575e8d3 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/certmanager.yaml @@ -4,7 +4,7 @@ apiVersion: cert-manager.io/v1 kind: Certificate metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -29,7 +29,7 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml b/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml index 1615f8dbb..2fed16d65 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/clusterrole.yaml @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -253,7 +253,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -271,7 +271,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml b/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml index 243b0c999..1669ce3d8 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/clusterrolebinding.yaml @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -25,7 +25,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml b/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml index be2829863..9acc3dea7 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/deployment.yaml @@ -4,7 +4,7 @@ apiVersion: apps/v1 kind: Deployment metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/role.yaml b/charts/opentelemetry-operator/examples/default/rendered/role.yaml index f5af8731e..cef6556f6 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/role.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/role.yaml @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml b/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml index 9e2943cd7..f09217ce2 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/rolebinding.yaml @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/service.yaml b/charts/opentelemetry-operator/examples/default/rendered/service.yaml index 9a512d10b..d8d147423 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/service.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/service.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Service metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ apiVersion: v1 kind: Service metadata: labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml b/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml index e2dec5b7a..74c67ddc1 100644 --- a/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml +++ b/charts/opentelemetry-operator/examples/default/rendered/serviceaccount.yaml @@ -6,7 +6,7 @@ metadata: name: opentelemetry-operator namespace: default labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm 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 3cb747db1..209eb6580 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 @@ -6,7 +6,7 @@ metadata: name: "example-opentelemetry-operator-cert-manager" namespace: default labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm 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 dea92528d..4fdd011bf 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 @@ -6,7 +6,7 @@ metadata: name: "example-opentelemetry-operator-metrics" namespace: default labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm @@ -43,7 +43,7 @@ metadata: name: "example-opentelemetry-operator-webhook" namespace: default labels: - helm.sh/chart: opentelemetry-operator-0.44.2 + helm.sh/chart: opentelemetry-operator-0.44.3 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.90.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/templates/_helpers.tpl b/charts/opentelemetry-operator/templates/_helpers.tpl index 4812314db..8e84476cf 100644 --- a/charts/opentelemetry-operator/templates/_helpers.tpl +++ b/charts/opentelemetry-operator/templates/_helpers.tpl @@ -97,8 +97,10 @@ a cert is loaded from an existing secret or is provided via `.Values` {{- $caCertEnc = index $prevSecret "data" "ca.crt" }} {{- if not $caCertEnc }} {{- $prevHook := (lookup "admissionregistration.k8s.io/v1" "MutatingWebhookConfiguration" .Release.Namespace (print (include "opentelemetry-operator.MutatingWebhookName" . ) "-mutation")) }} +{{- if not (eq (toString $prevHook) "") }} {{- $caCertEnc = (first $prevHook.webhooks).clientConfig.caBundle }} {{- end }} +{{- end }} {{- else }} {{- $altNames := list ( printf "%s-webhook.%s" (include "opentelemetry-operator.fullname" .) .Release.Namespace ) ( printf "%s-webhook.%s.svc" (include "opentelemetry-operator.fullname" .) .Release.Namespace ) -}} {{- $ca := genCA "opentelemetry-operator-operator-ca" 365 }}