From acfd09bc690a0d5ba2bf48ec0f0a024b32bb1439 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 2 Jul 2024 19:45:15 +0300 Subject: [PATCH] [operator] - Add extra labels/annotations on default alerts (#1226) --- charts/opentelemetry-operator/Chart.yaml | 2 +- .../operator-webhook-with-cert-manager.yaml | 4 +- .../default/rendered/certmanager.yaml | 4 +- .../default/rendered/clusterrole.yaml | 6 +-- .../default/rendered/clusterrolebinding.yaml | 4 +- .../examples/default/rendered/deployment.yaml | 2 +- .../examples/default/rendered/role.yaml | 2 +- .../default/rendered/rolebinding.yaml | 2 +- .../examples/default/rendered/service.yaml | 4 +- .../default/rendered/serviceaccount.yaml | 2 +- .../tests/test-certmanager-connection.yaml | 2 +- .../tests/test-service-connection.yaml | 4 +- .../templates/prometheusrule.yaml | 14 ++++++- .../opentelemetry-operator/values.schema.json | 37 ++++++++++++++++--- charts/opentelemetry-operator/values.yaml | 8 +++- 15 files changed, 69 insertions(+), 28 deletions(-) diff --git a/charts/opentelemetry-operator/Chart.yaml b/charts/opentelemetry-operator/Chart.yaml index 42364c03a..ff2f923d5 100644 --- a/charts/opentelemetry-operator/Chart.yaml +++ b/charts/opentelemetry-operator/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: opentelemetry-operator -version: 0.64.0 +version: 0.64.1 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 01f94621e..6d3e3edb2 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 91e977869..31462a0f3 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -30,7 +30,7 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 c452017bd..3834d5ba9 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -223,7 +223,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -242,7 +242,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 dd840f29d..89d61fded 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -26,7 +26,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 ccaca3d9c..0b28e97fe 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 11cbac647..8ea15aafe 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 9e63458d0..7289773ac 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 7d7be7b21..4d85c4b94 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -32,7 +32,7 @@ apiVersion: v1 kind: Service metadata: labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 7ca088d6e..bf9c0b266 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 afaa9fbb3..bb54ff860 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.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 41626e84f..b77a5c128 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.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm @@ -44,7 +44,7 @@ metadata: name: "example-opentelemetry-operator-webhook" namespace: default labels: - helm.sh/chart: opentelemetry-operator-0.64.0 + helm.sh/chart: opentelemetry-operator-0.64.1 app.kubernetes.io/name: opentelemetry-operator app.kubernetes.io/version: "0.103.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/opentelemetry-operator/templates/prometheusrule.yaml b/charts/opentelemetry-operator/templates/prometheusrule.yaml index 8f6b82d5f..7ae5590e2 100644 --- a/charts/opentelemetry-operator/templates/prometheusrule.yaml +++ b/charts/opentelemetry-operator/templates/prometheusrule.yaml @@ -11,7 +11,7 @@ metadata: {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} annotations: - {{- range $key, $value := .Values.manager.serviceMonitor.annotations }} + {{- range $key, $value := .Values.manager.prometheusRule.annotations }} {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} spec: @@ -27,16 +27,28 @@ spec: for: 5m labels: severity: warning + {{- with .Values.manager.prometheusRule.defaultRules.additionalRuleLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} annotations: description: '{{`Reconciliation errors for {{ $labels.controller }} is increasing and has now reached {{ humanize $value }} `}}' runbook_url: 'Check manager logs for reasons why this might happen' + {{- with .Values.manager.prometheusRule.defaultRules.additionalRuleAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} - alert: WorkqueueDepth expr: workqueue_depth{name="opentelemetrycollector"} > 0 for: 5m labels: severity: warning + {{- with .Values.manager.prometheusRule.defaultRules.additionalRuleLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} annotations: description: '{{`Queue depth for {{ $labels.name }} has reached {{ $value }} `}}' runbook_url: 'Check manager logs for reasons why this might happen' + {{- with .Values.manager.prometheusRule.defaultRules.additionalRuleAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- end }} diff --git a/charts/opentelemetry-operator/values.schema.json b/charts/opentelemetry-operator/values.schema.json index a926f6dd9..1116b813c 100644 --- a/charts/opentelemetry-operator/values.schema.json +++ b/charts/opentelemetry-operator/values.schema.json @@ -855,9 +855,10 @@ "default": {}, "title": "The defaultRules Schema", "required": [ - "enabled" + "enabled", + "additionalRuleLabels", + "additionalRuleAnnotations" ], - "additionalProperties": false, "properties": { "enabled": { "type": "boolean", @@ -866,10 +867,28 @@ "examples": [ false ] + }, + "additionalRuleLabels": { + "type": "object", + "default": {}, + "title": "The additionalRuleLabels Schema", + "required": [], + "properties": {}, + "examples": [{}] + }, + "additionalRuleAnnotations": { + "type": "object", + "default": {}, + "title": "The additionalRuleAnnotations Schema", + "required": [], + "properties": {}, + "examples": [{}] } }, "examples": [{ - "enabled": false + "enabled": false, + "additionalRuleLabels": {}, + "additionalRuleAnnotations": {} }] }, "extraLabels": { @@ -893,7 +912,9 @@ "enabled": false, "groups": [], "defaultRules": { - "enabled": false + "enabled": false, + "additionalRuleLabels": {}, + "additionalRuleAnnotations": {} }, "extraLabels": {}, "annotations": {} @@ -1124,7 +1145,9 @@ "enabled": false, "groups": [], "defaultRules": { - "enabled": false + "enabled": false, + "additionalRuleLabels": {}, + "additionalRuleAnnotations": {} }, "extraLabels": {}, "annotations": {} @@ -1904,7 +1927,9 @@ "enabled": false, "groups": [], "defaultRules": { - "enabled": false + "enabled": false, + "additionalRuleLabels": {}, + "additionalRuleAnnotations": {} }, "extraLabels": {}, "annotations": {} diff --git a/charts/opentelemetry-operator/values.yaml b/charts/opentelemetry-operator/values.yaml index a142e4500..47cda8281 100644 --- a/charts/opentelemetry-operator/values.yaml +++ b/charts/opentelemetry-operator/values.yaml @@ -124,9 +124,13 @@ manager: # Create default rules for monitoring the manager defaultRules: enabled: false - # additional labels on the PrometheusRule + ## Additional labels for PrometheusRule alerts + additionalRuleLabels: {} + ## Additional annotations for PrometheusRule alerts + additionalRuleAnnotations: {} + # additional labels on the PrometheusRule object extraLabels: {} - # add annotations on the PrometheusRule + # add annotations on the PrometheusRule object annotations: {} # Whether the operator should create RBAC permissions for collectors. See README.md for more information.