From 3d76ba47ee9117646f21c29f1454063fd3930dfa Mon Sep 17 00:00:00 2001 From: Todd Yan <38701187+Toaddyan@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:16:48 -0800 Subject: [PATCH] Optional annotations (#2586) * feat: Adding bool flag for pod annotations * docs: Adding required docs * nit: Adding optional kubebuilder validation comment and adding changelog --- .chloggen/optional-annotations.yaml | 16 +++++++++ apis/v1alpha1/opentelemetrycollector_types.go | 6 ++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 10 ++++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 10 ++++++ docs/api.md | 14 ++++++++ internal/manifests/collector/annotations.go | 11 ++++--- .../manifests/collector/annotations_test.go | 33 +++++++++++++++++++ 7 files changed, 96 insertions(+), 4 deletions(-) create mode 100755 .chloggen/optional-annotations.yaml diff --git a/.chloggen/optional-annotations.yaml b/.chloggen/optional-annotations.yaml new file mode 100755 index 0000000000..9c2dff4327 --- /dev/null +++ b/.chloggen/optional-annotations.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) +component: operator, target allocator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Adding a feature flag to disable default prometheus annotations + +# One or more tracking issues related to the change +issues: [2554] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index 22e9d8b68c..48bad7dd53 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -521,6 +521,12 @@ type MetricsConfigSpec struct { // +kubebuilder:validation:Optional // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Create ServiceMonitors for OpenTelemetry Collector" EnableMetrics bool `json:"enableMetrics,omitempty"` + // DisablePrometheusAnnotations controls the automatic addition of default Prometheus annotations + // ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path') + // + // +optional + // +kubebuilder:validation:Optional + DisablePrometheusAnnotations bool `json:"DisablePrometheusAnnotations,omitempty"` } // ObservabilitySpec defines how telemetry data gets handled. diff --git a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml index d156b4ae2a..c143aa9318 100644 --- a/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3867,6 +3867,11 @@ spec: metrics: description: Metrics defines the metrics configuration for operands. properties: + DisablePrometheusAnnotations: + description: DisablePrometheusAnnotations controls the automatic + addition of default Prometheus annotations ('prometheus.io/scrape', + 'prometheus.io/port', and 'prometheus.io/path') + type: boolean enableMetrics: description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the service @@ -5205,6 +5210,11 @@ spec: description: Metrics defines the metrics configuration for operands. properties: + DisablePrometheusAnnotations: + description: DisablePrometheusAnnotations controls the + automatic addition of default Prometheus annotations + ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path') + type: boolean enableMetrics: description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 6bc7ab7a5e..40cc76ab39 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -3864,6 +3864,11 @@ spec: metrics: description: Metrics defines the metrics configuration for operands. properties: + DisablePrometheusAnnotations: + description: DisablePrometheusAnnotations controls the automatic + addition of default Prometheus annotations ('prometheus.io/scrape', + 'prometheus.io/port', and 'prometheus.io/path') + type: boolean enableMetrics: description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for the service @@ -5202,6 +5207,11 @@ spec: description: Metrics defines the metrics configuration for operands. properties: + DisablePrometheusAnnotations: + description: DisablePrometheusAnnotations controls the + automatic addition of default Prometheus annotations + ('prometheus.io/scrape', 'prometheus.io/port', and 'prometheus.io/path') + type: boolean enableMetrics: description: EnableMetrics specifies if ServiceMonitor or PodMonitor(for sidecar mode) should be created for diff --git a/docs/api.md b/docs/api.md index 77094268c2..8fb054e25b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -17812,6 +17812,13 @@ Metrics defines the metrics configuration for operands.