From 2678fa1cf0aaaf101e5f86a243acf0e9c142f721 Mon Sep 17 00:00:00 2001 From: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> Date: Tue, 24 Feb 2026 10:41:02 +0100 Subject: [PATCH 1/5] feat(targetallocator): Expose missing Prometheus CR fields Signed-off-by: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> --- .chloggen/feat_ta-prom-cr-fields.yaml | 21 + apis/v1alpha1/convert.go | 64 ++- apis/v1alpha1/convert_test.go | 61 ++- apis/v1alpha1/opentelemetrycollector_types.go | 53 ++ apis/v1alpha1/zz_generated.deepcopy.go | 62 +++ apis/v1beta1/targetallocator_types.go | 36 +- apis/v1beta1/zz_generated.deepcopy.go | 30 ++ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 152 ++++++ .../opentelemetry.io_targetallocators.yaml | 112 ++++ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 152 ++++++ .../opentelemetry.io_targetallocators.yaml | 112 ++++ ...ntelemetry.io_opentelemetrycollectors.yaml | 152 ++++++ .../opentelemetry.io_targetallocators.yaml | 112 ++++ docs/api/opentelemetrycollectors.md | 495 +++++++++++++++++- docs/api/targetallocators.md | 401 +++++++++++++- .../manifests/targetallocator/configmap.go | 18 + .../02-assert.yaml | 12 +- .../02-install.yaml | 17 +- 20 files changed, 2039 insertions(+), 27 deletions(-) create mode 100644 .chloggen/feat_ta-prom-cr-fields.yaml diff --git a/.chloggen/feat_ta-prom-cr-fields.yaml b/.chloggen/feat_ta-prom-cr-fields.yaml new file mode 100644 index 0000000000..6eeaf44e63 --- /dev/null +++ b/.chloggen/feat_ta-prom-cr-fields.yaml @@ -0,0 +1,21 @@ +# 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. collector, target allocator, auto-instrumentation, opamp, github action) +component: target allocator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Expose missing Prometheus CR fields in the Operator API + +# One or more tracking issues related to the change +# Issue 5517 does not exist... +issues: [5517] + +# (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: | + Added `podMonitorNamespaceSelector`, `serviceMonitorNamespaceSelector`, `scrapeConfigNamespaceSelector`, + `probeNamespaceSelector`, `evaluationInterval`, and `scrapeProtocols` to the `prometheusCR` + configuration within the `TargetAllocator` and `OpenTelemetryCollector` + APIs to achieve feature parity with the underlying Target Allocator. diff --git a/apis/v1alpha1/convert.go b/apis/v1alpha1/convert.go index 360aa19449..11d8e7f7b7 100644 --- a/apis/v1alpha1/convert.go +++ b/apis/v1alpha1/convert.go @@ -185,16 +185,20 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde Enabled: in.Enabled, Affinity: in.Affinity, PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ - Enabled: in.PrometheusCR.Enabled, - ScrapeInterval: in.PrometheusCR.ScrapeInterval, - ScrapeClasses: in.PrometheusCR.ScrapeClasses, + Enabled: in.PrometheusCR.Enabled, + ScrapeInterval: in.PrometheusCR.ScrapeInterval, + EvaluationInterval: in.PrometheusCR.EvaluationInterval, + ScrapeProtocols: in.PrometheusCR.ScrapeProtocols, + ScrapeClasses: in.PrometheusCR.ScrapeClasses, // prometheus_cr.pod_monitor_selector shouldn't be nil when selector is empty - PodMonitorSelector: &metav1.LabelSelector{ - MatchLabels: in.PrometheusCR.PodMonitorSelector, - }, - ServiceMonitorSelector: &metav1.LabelSelector{ - MatchLabels: in.PrometheusCR.ServiceMonitorSelector, - }, + PodMonitorSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.PodMonitorSelector}, + PodMonitorNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.PodMonitorNamespaceSelector}, + ServiceMonitorSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ServiceMonitorSelector}, + ServiceMonitorNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ServiceMonitorNamespaceSelector}, + ScrapeConfigSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ScrapeConfigSelector}, + ScrapeConfigNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ScrapeConfigNamespaceSelector}, + ProbeSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ProbeSelector}, + ProbeNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ProbeNamespaceSelector}, }, SecurityContext: in.SecurityContext, PodSecurityContext: in.PodSecurityContext, @@ -441,10 +445,34 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat if in.PrometheusCR.PodMonitorSelector != nil { podMonitorSelector = in.PrometheusCR.PodMonitorSelector.MatchLabels } + var podMonitorNamespaceSelector map[string]string + if in.PrometheusCR.PodMonitorNamespaceSelector != nil { + podMonitorNamespaceSelector = in.PrometheusCR.PodMonitorNamespaceSelector.MatchLabels + } var serviceMonitorSelector map[string]string if in.PrometheusCR.ServiceMonitorSelector != nil { serviceMonitorSelector = in.PrometheusCR.ServiceMonitorSelector.MatchLabels } + var serviceMonitorNamespaceSelector map[string]string + if in.PrometheusCR.ServiceMonitorNamespaceSelector != nil { + serviceMonitorNamespaceSelector = in.PrometheusCR.ServiceMonitorNamespaceSelector.MatchLabels + } + var scrapeConfigSelector map[string]string + if in.PrometheusCR.ScrapeConfigSelector != nil { + scrapeConfigSelector = in.PrometheusCR.ScrapeConfigSelector.MatchLabels + } + var scrapeConfigNamespaceSelector map[string]string + if in.PrometheusCR.ScrapeConfigNamespaceSelector != nil { + scrapeConfigNamespaceSelector = in.PrometheusCR.ScrapeConfigNamespaceSelector.MatchLabels + } + var probeSelector map[string]string + if in.PrometheusCR.ProbeSelector != nil { + probeSelector = in.PrometheusCR.ProbeSelector.MatchLabels + } + var probeNamespaceSelector map[string]string + if in.PrometheusCR.ProbeNamespaceSelector != nil { + probeNamespaceSelector = in.PrometheusCR.ProbeNamespaceSelector.MatchLabels + } return OpenTelemetryTargetAllocator{ Replicas: in.Replicas, @@ -457,11 +485,19 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat Enabled: in.Enabled, Affinity: in.Affinity, PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ - Enabled: in.PrometheusCR.Enabled, - ScrapeInterval: in.PrometheusCR.ScrapeInterval, - ScrapeClasses: in.PrometheusCR.ScrapeClasses, - PodMonitorSelector: podMonitorSelector, - ServiceMonitorSelector: serviceMonitorSelector, + Enabled: in.PrometheusCR.Enabled, + ScrapeInterval: in.PrometheusCR.ScrapeInterval, + EvaluationInterval: in.PrometheusCR.EvaluationInterval, + ScrapeProtocols: in.PrometheusCR.ScrapeProtocols, + ScrapeClasses: in.PrometheusCR.ScrapeClasses, + PodMonitorSelector: podMonitorSelector, + PodMonitorNamespaceSelector: podMonitorNamespaceSelector, + ServiceMonitorSelector: serviceMonitorSelector, + ServiceMonitorNamespaceSelector: serviceMonitorNamespaceSelector, + ScrapeConfigSelector: scrapeConfigSelector, + ScrapeConfigNamespaceSelector: scrapeConfigNamespaceSelector, + ProbeSelector: probeSelector, + ProbeNamespaceSelector: probeNamespaceSelector, }, SecurityContext: in.SecurityContext, PodSecurityContext: in.PodSecurityContext, diff --git a/apis/v1alpha1/convert_test.go b/apis/v1alpha1/convert_test.go index 67f6ba60c7..809dbd698e 100644 --- a/apis/v1alpha1/convert_test.go +++ b/apis/v1alpha1/convert_test.go @@ -358,8 +358,14 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { TargetAllocator: OpenTelemetryTargetAllocator{ PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ // nil or empty map means select everything - PodMonitorSelector: nil, - ServiceMonitorSelector: nil, + PodMonitorSelector: nil, + ServiceMonitorSelector: nil, + PodMonitorNamespaceSelector: nil, + ServiceMonitorNamespaceSelector: nil, + ScrapeConfigSelector: nil, + ScrapeConfigNamespaceSelector: nil, + ProbeSelector: nil, + ProbeNamespaceSelector: nil, }, }, }, @@ -373,13 +379,32 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { // empty LabelSelector mean select everything assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector)) assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector)) + assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector)) err = colalpha1.ConvertFrom(&colbeta1) require.NoError(t, err) assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) + assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) }) t.Run("empty-selectors", func(t *testing.T) { colalpha1 := OpenTelemetryCollector{ @@ -387,8 +412,14 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { TargetAllocator: OpenTelemetryTargetAllocator{ PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ // nil or empty map means select everything - PodMonitorSelector: map[string]string{}, - ServiceMonitorSelector: map[string]string{}, + PodMonitorSelector: map[string]string{}, + ServiceMonitorSelector: map[string]string{}, + PodMonitorNamespaceSelector: map[string]string{}, + ServiceMonitorNamespaceSelector: map[string]string{}, + ScrapeConfigSelector: map[string]string{}, + ScrapeConfigNamespaceSelector: map[string]string{}, + ProbeSelector: map[string]string{}, + ProbeNamespaceSelector: map[string]string{}, }, }, }, @@ -402,11 +433,23 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { // empty LabelSelector mean select everything assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) + assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) err = colalpha1.ConvertFrom(&colbeta1) require.NoError(t, err) assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) + assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) }) } @@ -559,8 +602,14 @@ func TestConvertTo(t *testing.T) { }, TargetAllocator: v1beta1.TargetAllocatorEmbedded{ PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ - PodMonitorSelector: &metav1.LabelSelector{}, - ServiceMonitorSelector: &metav1.LabelSelector{}, + PodMonitorSelector: &metav1.LabelSelector{}, + ServiceMonitorSelector: &metav1.LabelSelector{}, + PodMonitorNamespaceSelector: &metav1.LabelSelector{}, + ServiceMonitorNamespaceSelector: &metav1.LabelSelector{}, + ScrapeConfigSelector: &metav1.LabelSelector{}, + ScrapeConfigNamespaceSelector: &metav1.LabelSelector{}, + ProbeSelector: &metav1.LabelSelector{}, + ProbeNamespaceSelector: &metav1.LabelSelector{}, }, }, Config: v1beta1.Config{ diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index bc579fd17d..5b25e0f3ba 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -385,12 +385,29 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct { // Enabled indicates whether to use a PrometheusOperator custom resources as targets or not. // +optional Enabled bool `json:"enabled,omitempty"` + // AllowNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (allow list). This is mutually exclusive with DenyNamespaces. + // +optional + AllowNamespaces []string `json:"allowNamespaces,omitempty"` + // DenyNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (deny list). This is mutually exclusive with AllowNamespaces. + // +optional + DenyNamespaces []string `json:"denyNamespaces,omitempty"` // Interval between consecutive scrapes. Equivalent to the same setting on the Prometheus CRD. // // Default: "30s" // +kubebuilder:default:="30s" // +kubebuilder:validation:Format:=duration ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` + // Default interval between rule evaluations. + // + // Default: "30s" + // +kubebuilder:default:="30s" + // +kubebuilder:validation:Format:=duration + // +optional + EvaluationInterval *metav1.Duration `json:"evaluationInterval,omitempty"` + // ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the + // protocols supported by Prometheus in order of preference (from most to least preferred). + // +optional + ScrapeProtocols []string `json:"scrapeProtocols,omitempty"` // ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration. // If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass. // +optional @@ -403,12 +420,48 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct { // Empty or nil map matches all pod monitors. // +optional PodMonitorSelector map[string]string `json:"podMonitorSelector,omitempty"` + // Namespaces to be selected for PodMonitor discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // namespace's meta labels. The requirements are ANDed. + // Empty or nil map matches all namespaces. + // +optional + PodMonitorNamespaceSelector map[string]string `json:"podMonitorNamespaceSelector,omitempty"` // ServiceMonitors to be selected for target discovery. // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a // ServiceMonitor's meta labels. The requirements are ANDed. // Empty or nil map matches all service monitors. // +optional ServiceMonitorSelector map[string]string `json:"serviceMonitorSelector,omitempty"` + // Namespaces to be selected for ServiceMonitor discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // namespace's meta labels. The requirements are ANDed. + // Empty or nil map matches all namespaces. + // +optional + ServiceMonitorNamespaceSelector map[string]string `json:"serviceMonitorNamespaceSelector,omitempty"` + // ScrapeConfigs to be selected for target discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // ScrapeConfig's meta labels. The requirements are ANDed. + // Empty or nil map matches all scrape configs. + // +optional + ScrapeConfigSelector map[string]string `json:"scrapeConfigSelector,omitempty"` + // Namespaces to be selected for ScrapeConfig discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // namespace's meta labels. The requirements are ANDed. + // Empty or nil map matches all namespaces. + // +optional + ScrapeConfigNamespaceSelector map[string]string `json:"scrapeConfigNamespaceSelector,omitempty"` + // Probes to be selected for target discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // Probe's meta labels. The requirements are ANDed. + // Empty or nil map matches all probes. + // +optional + ProbeSelector map[string]string `json:"probeSelector,omitempty"` + // Namespaces to be selected for Probe discovery. + // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a + // namespace's meta labels. The requirements are ANDed. + // Empty or nil map matches all namespaces. + // +optional + ProbeNamespaceSelector map[string]string `json:"probeNamespaceSelector,omitempty"` } // ScaleSubresourceStatus defines the observed state of the OpenTelemetryCollector's diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 20820c075f..c5ee589e1d 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -1297,11 +1297,31 @@ func (in *OpenTelemetryTargetAllocator) DeepCopy() *OpenTelemetryTargetAllocator // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTelemetryTargetAllocatorPrometheusCR) { *out = *in + if in.AllowNamespaces != nil { + in, out := &in.AllowNamespaces, &out.AllowNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.DenyNamespaces != nil { + in, out := &in.DenyNamespaces, &out.DenyNamespaces + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ScrapeInterval != nil { in, out := &in.ScrapeInterval, &out.ScrapeInterval *out = new(metav1.Duration) **out = **in } + if in.EvaluationInterval != nil { + in, out := &in.EvaluationInterval, &out.EvaluationInterval + *out = new(metav1.Duration) + **out = **in + } + if in.ScrapeProtocols != nil { + in, out := &in.ScrapeProtocols, &out.ScrapeProtocols + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ScrapeClasses != nil { in, out := &in.ScrapeClasses, &out.ScrapeClasses *out = make([]v1beta1.AnyConfig, len(*in)) @@ -1316,6 +1336,13 @@ func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTeleme (*out)[key] = val } } + if in.PodMonitorNamespaceSelector != nil { + in, out := &in.PodMonitorNamespaceSelector, &out.PodMonitorNamespaceSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.ServiceMonitorSelector != nil { in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector *out = make(map[string]string, len(*in)) @@ -1323,6 +1350,41 @@ func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTeleme (*out)[key] = val } } + if in.ServiceMonitorNamespaceSelector != nil { + in, out := &in.ServiceMonitorNamespaceSelector, &out.ServiceMonitorNamespaceSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.ScrapeConfigSelector != nil { + in, out := &in.ScrapeConfigSelector, &out.ScrapeConfigSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.ScrapeConfigNamespaceSelector != nil { + in, out := &in.ScrapeConfigNamespaceSelector, &out.ScrapeConfigNamespaceSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.ProbeSelector != nil { + in, out := &in.ProbeSelector, &out.ProbeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.ProbeNamespaceSelector != nil { + in, out := &in.ProbeNamespaceSelector, &out.ProbeNamespaceSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetryTargetAllocatorPrometheusCR. diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go index 5f745a8b06..80963d2edc 100644 --- a/apis/v1beta1/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -19,12 +19,22 @@ type TargetAllocatorPrometheusCR struct { // +optional DenyNamespaces []string `json:"denyNamespaces,omitempty"` // Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. - //Equivalent to the same setting on the Prometheus CR. // // Default: "30s" // +kubebuilder:default:="30s" // +kubebuilder:validation:Format:=duration ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` + // Default interval between rule evaluations. + // + // Default: "30s" + // +kubebuilder:default:="30s" + // +kubebuilder:validation:Format:=duration + // +optional + EvaluationInterval *metav1.Duration `json:"evaluationInterval,omitempty"` + // ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the + // protocols supported by Prometheus in order of preference (from most to least preferred). + // +optional + ScrapeProtocols []string `json:"scrapeProtocols,omitempty"` // ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration. // If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass. // +optional @@ -37,24 +47,48 @@ type TargetAllocatorPrometheusCR struct { // label selector matches no objects. // +optional PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"` + // Namespaces to be selected for PodMonitor discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"` // ServiceMonitors to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"` + // Namespaces to be selected for ServiceMonitor discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"` // ScrapeConfigs to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional ScrapeConfigSelector *metav1.LabelSelector `json:"scrapeConfigSelector,omitempty"` + // Namespaces to be selected for ScrapeConfig discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ScrapeConfigNamespaceSelector *metav1.LabelSelector `json:"scrapeConfigNamespaceSelector,omitempty"` // Probes to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional ProbeSelector *metav1.LabelSelector `json:"probeSelector,omitempty"` + // Namespaces to be selected for Probe discovery. + // A label selector is a label query over a set of resources. The result of matchLabels and + // matchExpressions are ANDed. An empty label selector matches all objects. A null + // label selector matches no objects. + // +optional + ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"` } type ( diff --git a/apis/v1beta1/zz_generated.deepcopy.go b/apis/v1beta1/zz_generated.deepcopy.go index fcbbffa62b..3f32a0c0e8 100644 --- a/apis/v1beta1/zz_generated.deepcopy.go +++ b/apis/v1beta1/zz_generated.deepcopy.go @@ -829,6 +829,16 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.Duration) **out = **in } + if in.EvaluationInterval != nil { + in, out := &in.EvaluationInterval, &out.EvaluationInterval + *out = new(metav1.Duration) + **out = **in + } + if in.ScrapeProtocols != nil { + in, out := &in.ScrapeProtocols, &out.ScrapeProtocols + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ScrapeClasses != nil { in, out := &in.ScrapeClasses, &out.ScrapeClasses *out = make([]AnyConfig, len(*in)) @@ -841,21 +851,41 @@ func (in *TargetAllocatorPrometheusCR) DeepCopyInto(out *TargetAllocatorPromethe *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.PodMonitorNamespaceSelector != nil { + in, out := &in.PodMonitorNamespaceSelector, &out.PodMonitorNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.ServiceMonitorSelector != nil { in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ServiceMonitorNamespaceSelector != nil { + in, out := &in.ServiceMonitorNamespaceSelector, &out.ServiceMonitorNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.ScrapeConfigSelector != nil { in, out := &in.ScrapeConfigSelector, &out.ScrapeConfigSelector *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ScrapeConfigNamespaceSelector != nil { + in, out := &in.ScrapeConfigNamespaceSelector, &out.ScrapeConfigNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } if in.ProbeSelector != nil { in, out := &in.ProbeSelector, &out.ProbeSelector *out = new(metav1.LabelSelector) (*in).DeepCopyInto(*out) } + if in.ProbeNamespaceSelector != nil { + in, out := &in.ProbeNamespaceSelector, &out.ProbeNamespaceSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetAllocatorPrometheusCR. diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index a2d5fbf54d..6cde2bc348 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-18T12:31:45Z" + createdAt: "2026-02-24T09:23:18Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index d3de7fc169..3af55ecc13 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3363,22 +3363,62 @@ spec: type: object prometheusCR: properties: + allowNamespaces: + items: + type: string + type: array + denyNamespaces: + items: + type: string + type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + additionalProperties: + type: string + type: object podMonitorSelector: additionalProperties: type: string type: object + probeNamespaceSelector: + additionalProperties: + type: string + type: object + probeSelector: + additionalProperties: + type: string + type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + additionalProperties: + type: string + type: object + scrapeConfigSelector: + additionalProperties: + type: string + type: object scrapeInterval: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + additionalProperties: + type: string + type: object serviceMonitorSelector: additionalProperties: type: string @@ -8266,6 +8306,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -8292,6 +8362,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -8324,6 +8420,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -8354,6 +8476,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml index 8207714970..0f1e3f1144 100644 --- a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml @@ -2469,6 +2469,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -2495,6 +2525,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -2527,6 +2583,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -2557,6 +2639,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index a3b3dffacb..1bb25c3ed9 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-18T12:31:45Z" + createdAt: "2026-02-24T09:23:18Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index ff3e127fbc..7e6dd92870 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3362,22 +3362,62 @@ spec: type: object prometheusCR: properties: + allowNamespaces: + items: + type: string + type: array + denyNamespaces: + items: + type: string + type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + additionalProperties: + type: string + type: object podMonitorSelector: additionalProperties: type: string type: object + probeNamespaceSelector: + additionalProperties: + type: string + type: object + probeSelector: + additionalProperties: + type: string + type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + additionalProperties: + type: string + type: object + scrapeConfigSelector: + additionalProperties: + type: string + type: object scrapeInterval: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + additionalProperties: + type: string + type: object serviceMonitorSelector: additionalProperties: type: string @@ -8265,6 +8305,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -8291,6 +8361,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -8323,6 +8419,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -8353,6 +8475,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml index 8207714970..0f1e3f1144 100644 --- a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml @@ -2469,6 +2469,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -2495,6 +2525,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -2527,6 +2583,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -2557,6 +2639,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 415d40bab6..2d222aa911 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -3349,22 +3349,62 @@ spec: type: object prometheusCR: properties: + allowNamespaces: + items: + type: string + type: array + denyNamespaces: + items: + type: string + type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + additionalProperties: + type: string + type: object podMonitorSelector: additionalProperties: type: string type: object + probeNamespaceSelector: + additionalProperties: + type: string + type: object + probeSelector: + additionalProperties: + type: string + type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + additionalProperties: + type: string + type: object + scrapeConfigSelector: + additionalProperties: + type: string + type: object scrapeInterval: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + additionalProperties: + type: string + type: object serviceMonitorSelector: additionalProperties: type: string @@ -8252,6 +8292,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -8278,6 +8348,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -8310,6 +8406,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -8340,6 +8462,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index df0ae9cb67..8a9a25ffd3 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -2467,6 +2467,36 @@ spec: type: array enabled: type: boolean + evaluationInterval: + default: 30s + format: duration + type: string + podMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic podMonitorSelector: properties: matchExpressions: @@ -2493,6 +2523,32 @@ spec: type: object type: object x-kubernetes-map-type: atomic + probeNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic probeSelector: properties: matchExpressions: @@ -2525,6 +2581,32 @@ spec: type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true + scrapeConfigNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic scrapeConfigSelector: properties: matchExpressions: @@ -2555,6 +2637,36 @@ spec: default: 30s format: duration type: string + scrapeProtocols: + items: + type: string + type: array + serviceMonitorNamespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic serviceMonitorSelector: properties: matchExpressions: diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index 37d0cfa8e9..62734f5a0d 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -13975,12 +13975,48 @@ All CR instances which the ServiceAccount has access to will be retrieved. This + allowNamespaces + []string + + AllowNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (allow list). This is mutually exclusive with DenyNamespaces.
+ + false + + denyNamespaces + []string + + DenyNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (deny list). This is mutually exclusive with AllowNamespaces.
+ + false + enabled boolean Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false + + evaluationInterval + string + + Default interval between rule evaluations. + +Default: "30s"
+
+ Format: duration
+ Default: 30s
+ + false + + podMonitorNamespaceSelector + map[string]string + + Namespaces to be selected for PodMonitor discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +namespace's meta labels. The requirements are ANDed. +Empty or nil map matches all namespaces.
+ + false podMonitorSelector map[string]string @@ -13991,6 +14027,26 @@ PodMonitor's meta labels. The requirements are ANDed. Empty or nil map matches all pod monitors.
false + + probeNamespaceSelector + map[string]string + + Namespaces to be selected for Probe discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +namespace's meta labels. The requirements are ANDed. +Empty or nil map matches all namespaces.
+ + false + + probeSelector + map[string]string + + Probes to be selected for target discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +Probe's meta labels. The requirements are ANDed. +Empty or nil map matches all probes.
+ + false scrapeClasses []object @@ -13999,6 +14055,26 @@ Empty or nil map matches all pod monitors.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false + + scrapeConfigNamespaceSelector + map[string]string + + Namespaces to be selected for ScrapeConfig discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +namespace's meta labels. The requirements are ANDed. +Empty or nil map matches all namespaces.
+ + false + + scrapeConfigSelector + map[string]string + + ScrapeConfigs to be selected for target discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +ScrapeConfig's meta labels. The requirements are ANDed. +Empty or nil map matches all scrape configs.
+ + false scrapeInterval string @@ -14011,6 +14087,24 @@ Default: "30s"
Default: 30s
false + + scrapeProtocols + []string + + ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the +protocols supported by Prometheus in order of preference (from most to least preferred).
+ + false + + serviceMonitorNamespaceSelector + map[string]string + + Namespaces to be selected for ServiceMonitor discovery. +This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a +namespace's meta labels. The requirements are ANDed. +Empty or nil map matches all namespaces.
+ + false serviceMonitorSelector map[string]string @@ -34722,6 +34816,28 @@ All CR instances which the ServiceAccount has access to will be retrieved. This Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false + + evaluationInterval + string + + Default interval between rule evaluations. + +Default: "30s"
+
+ Format: duration
+ Default: 30s
+ + false + + podMonitorNamespaceSelector + object + + Namespaces to be selected for PodMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false podMonitorSelector object @@ -34729,6 +34845,16 @@ All CR instances which the ServiceAccount has access to will be retrieved. This PodMonitors to be selected for target discovery. A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + probeNamespaceSelector + object + + Namespaces to be selected for Probe discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false @@ -34750,6 +34876,16 @@ label selector matches no objects.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false + + scrapeConfigNamespaceSelector + object + + Namespaces to be selected for ScrapeConfig discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false scrapeConfigSelector object @@ -34765,7 +34901,6 @@ label selector matches no objects.
string Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. -Equivalent to the same setting on the Prometheus CR. Default: "30s"

@@ -34773,6 +34908,24 @@ Default: "30s"
Default: 30s
false + + scrapeProtocols + []string + + ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the +protocols supported by Prometheus in order of preference (from most to least preferred).
+ + false + + serviceMonitorNamespaceSelector + object + + Namespaces to be selected for ServiceMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false serviceMonitorSelector object @@ -34787,6 +34940,91 @@ label selector matches no objects.
+### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.podMonitorNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for PodMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.podMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrpodmonitornamespaceselector) + + + +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + ### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.podMonitorSelector [↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) @@ -34831,6 +35069,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for Probe discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.probeNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrprobenamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -34916,6 +35239,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for ScrapeConfig discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.scrapeConfigNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrscrapeconfignamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -35001,6 +35409,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.serviceMonitorNamespaceSelector +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscr-1) + + + +Namespaces to be selected for ServiceMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### OpenTelemetryCollector.spec.targetAllocator.prometheusCR.serviceMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#opentelemetrycollectorspectargetallocatorprometheuscrservicemonitornamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. diff --git a/docs/api/targetallocators.md b/docs/api/targetallocators.md index d9c30c1f1d..e8bc81c4f8 100644 --- a/docs/api/targetallocators.md +++ b/docs/api/targetallocators.md @@ -10326,6 +10326,28 @@ PrometheusCR defines the configuration for the retrieval of PrometheusOperator C Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false + + evaluationInterval + string + + Default interval between rule evaluations. + +Default: "30s"
+
+ Format: duration
+ Default: 30s
+ + false + + podMonitorNamespaceSelector + object + + Namespaces to be selected for PodMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false podMonitorSelector object @@ -10333,6 +10355,16 @@ PrometheusCR defines the configuration for the retrieval of PrometheusOperator C PodMonitors to be selected for target discovery. A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false + + probeNamespaceSelector + object + + Namespaces to be selected for Probe discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
false @@ -10354,6 +10386,16 @@ label selector matches no objects.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false + + scrapeConfigNamespaceSelector + object + + Namespaces to be selected for ScrapeConfig discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false scrapeConfigSelector object @@ -10369,7 +10411,6 @@ label selector matches no objects.
string Default interval between consecutive scrapes. Intervals set in ServiceMonitors and PodMonitors override it. -Equivalent to the same setting on the Prometheus CR. Default: "30s"

@@ -10377,6 +10418,24 @@ Default: "30s"
Default: 30s
false + + scrapeProtocols + []string + + ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the +protocols supported by Prometheus in order of preference (from most to least preferred).
+ + false + + serviceMonitorNamespaceSelector + object + + Namespaces to be selected for ServiceMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects.
+ + false serviceMonitorSelector object @@ -10391,6 +10450,91 @@ label selector matches no objects.
+### TargetAllocator.spec.prometheusCR.podMonitorNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for PodMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### TargetAllocator.spec.prometheusCR.podMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrpodmonitornamespaceselector) + + + +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + ### TargetAllocator.spec.prometheusCR.podMonitorSelector [↩ Parent](#targetallocatorspecprometheuscr) @@ -10435,6 +10579,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### TargetAllocator.spec.prometheusCR.probeNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for Probe discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### TargetAllocator.spec.prometheusCR.probeNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrprobenamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -10520,6 +10749,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### TargetAllocator.spec.prometheusCR.scrapeConfigNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for ScrapeConfig discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### TargetAllocator.spec.prometheusCR.scrapeConfigNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrscrapeconfignamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. @@ -10605,6 +10919,91 @@ operator is "In", and the values array contains only "value". The requirements a +A label selector requirement is a selector that contains values, a key, and an operator that +relates the key and values. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
keystring + key is the label key that the selector applies to.
+
true
operatorstring + operator represents a key's relationship to a set of values. +Valid operators are In, NotIn, Exists and DoesNotExist.
+
true
values[]string + values is an array of string values. If the operator is In or NotIn, +the values array must be non-empty. If the operator is Exists or DoesNotExist, +the values array must be empty. This array is replaced during a strategic +merge patch.
+
false
+ + +### TargetAllocator.spec.prometheusCR.serviceMonitorNamespaceSelector +[↩ Parent](#targetallocatorspecprometheuscr) + + + +Namespaces to be selected for ServiceMonitor discovery. +A label selector is a label query over a set of resources. The result of matchLabels and +matchExpressions are ANDed. An empty label selector matches all objects. A null +label selector matches no objects. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
matchExpressions[]object + matchExpressions is a list of label selector requirements. The requirements are ANDed.
+
false
matchLabelsmap[string]string + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels +map is equivalent to an element of matchExpressions, whose key field is "key", the +operator is "In", and the values array contains only "value". The requirements are ANDed.
+
false
+ + +### TargetAllocator.spec.prometheusCR.serviceMonitorNamespaceSelector.matchExpressions[index] +[↩ Parent](#targetallocatorspecprometheuscrservicemonitornamespaceselector) + + + A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index 1162c83731..feccf099fa 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -93,6 +93,12 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { if taSpec.PrometheusCR.ScrapeInterval.Size() > 0 { prometheusCRConfig["scrape_interval"] = taSpec.PrometheusCR.ScrapeInterval.Duration } + if taSpec.PrometheusCR.EvaluationInterval.Size() > 0 { + prometheusCRConfig["evaluation_interval"] = taSpec.PrometheusCR.EvaluationInterval.Duration + } + if taSpec.PrometheusCR.ScrapeProtocols != nil { + prometheusCRConfig["scrape_protocols"] = taSpec.PrometheusCR.ScrapeProtocols + } if taSpec.PrometheusCR.ScrapeClasses != nil { prometheusCRConfig["scrape_classes"] = taSpec.PrometheusCR.ScrapeClasses @@ -107,12 +113,24 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { } prometheusCRConfig["service_monitor_selector"] = taSpec.PrometheusCR.ServiceMonitorSelector + if taSpec.PrometheusCR.ServiceMonitorNamespaceSelector != nil { + prometheusCRConfig["service_monitor_namespace_selector"] = taSpec.PrometheusCR.ServiceMonitorNamespaceSelector + } prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector + if taSpec.PrometheusCR.PodMonitorNamespaceSelector != nil { + prometheusCRConfig["pod_monitor_namespace_selector"] = taSpec.PrometheusCR.PodMonitorNamespaceSelector + } prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector + if taSpec.PrometheusCR.ScrapeConfigNamespaceSelector != nil { + prometheusCRConfig["scrape_config_namespace_selector"] = taSpec.PrometheusCR.ScrapeConfigNamespaceSelector + } prometheusCRConfig["probe_selector"] = taSpec.PrometheusCR.ProbeSelector + if taSpec.PrometheusCR.ProbeNamespaceSelector != nil { + prometheusCRConfig["probe_namespace_selector"] = taSpec.PrometheusCR.ProbeNamespaceSelector + } taConfig["prometheus_cr"] = prometheusCRConfig } diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml index 91f960eedb..ccedd3aff6 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -24,6 +24,16 @@ data: ( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false ( contains(@, join(':', ['matchlabels', ' {}}'])) ): false ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false + ( contains(@, 'evaluation_interval: 2m') ): true + ( contains(@, '- PrometheusText1.0.0') ): true + ( contains(@, 'service_monitor_namespace_selector:') ): true + ( contains(@, 'pod_monitor_namespace_selector:') ): true + ( contains(@, 'scrape_config_namespace_selector:') ): true + ( contains(@, 'probe_namespace_selector:') ): true + ( contains(@, 'ns-label: service') ): true + ( contains(@, 'ns-label: pod') ): true + ( contains(@, 'ns-label: scrape') ): true + ( contains(@, 'ns-label: probe') ): true kind: ConfigMap metadata: name: prometheus-cr-v1beta1-targetallocator @@ -54,4 +64,4 @@ kind: Job metadata: name: check-ta-jobs-probes-v1beta1 status: - succeeded: 1 \ No newline at end of file + succeeded: 1 diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml index 4c7751361f..8584dbbf20 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml @@ -27,8 +27,23 @@ spec: prometheusCR: enabled: true scrapeInterval: 1s + evaluationInterval: 2m + scrapeProtocols: + - PrometheusText1.0.0 scrapeConfigSelector: {} probeSelector: {} + podMonitorNamespaceSelector: + matchLabels: + ns-label: pod + serviceMonitorNamespaceSelector: + matchLabels: + ns-label: service + scrapeConfigNamespaceSelector: + matchLabels: + ns-label: scrape + probeNamespaceSelector: + matchLabels: + ns-label: probe scrapeClasses: - name: tls-config tlsConfig: @@ -154,4 +169,4 @@ spec: args: - /bin/sh - -c - - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" \ No newline at end of file + - curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "blackbox-exporter" From 4d03234df2dbe4eb07e98f721dc25425bdb60a45 Mon Sep 17 00:00:00 2001 From: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> Date: Tue, 24 Feb 2026 16:12:52 +0100 Subject: [PATCH 2/5] refactor: Remove v1alpha1 changes Signed-off-by: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> --- .chloggen/feat_ta-prom-cr-fields.yaml | 3 +- apis/v1alpha1/convert.go | 64 +++---------- apis/v1alpha1/convert_test.go | 61 ++---------- apis/v1alpha1/opentelemetrycollector_types.go | 53 ----------- apis/v1alpha1/zz_generated.deepcopy.go | 62 ------------ ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 40 -------- ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 40 -------- ...ntelemetry.io_opentelemetrycollectors.yaml | 40 -------- docs/api/opentelemetrycollectors.md | 94 ------------------- 11 files changed, 23 insertions(+), 438 deletions(-) diff --git a/.chloggen/feat_ta-prom-cr-fields.yaml b/.chloggen/feat_ta-prom-cr-fields.yaml index 6eeaf44e63..d41803c536 100644 --- a/.chloggen/feat_ta-prom-cr-fields.yaml +++ b/.chloggen/feat_ta-prom-cr-fields.yaml @@ -8,8 +8,7 @@ component: target allocator note: Expose missing Prometheus CR fields in the Operator API # One or more tracking issues related to the change -# Issue 5517 does not exist... -issues: [5517] +issues: [1934] # (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. diff --git a/apis/v1alpha1/convert.go b/apis/v1alpha1/convert.go index 11d8e7f7b7..360aa19449 100644 --- a/apis/v1alpha1/convert.go +++ b/apis/v1alpha1/convert.go @@ -185,20 +185,16 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde Enabled: in.Enabled, Affinity: in.Affinity, PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ - Enabled: in.PrometheusCR.Enabled, - ScrapeInterval: in.PrometheusCR.ScrapeInterval, - EvaluationInterval: in.PrometheusCR.EvaluationInterval, - ScrapeProtocols: in.PrometheusCR.ScrapeProtocols, - ScrapeClasses: in.PrometheusCR.ScrapeClasses, + Enabled: in.PrometheusCR.Enabled, + ScrapeInterval: in.PrometheusCR.ScrapeInterval, + ScrapeClasses: in.PrometheusCR.ScrapeClasses, // prometheus_cr.pod_monitor_selector shouldn't be nil when selector is empty - PodMonitorSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.PodMonitorSelector}, - PodMonitorNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.PodMonitorNamespaceSelector}, - ServiceMonitorSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ServiceMonitorSelector}, - ServiceMonitorNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ServiceMonitorNamespaceSelector}, - ScrapeConfigSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ScrapeConfigSelector}, - ScrapeConfigNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ScrapeConfigNamespaceSelector}, - ProbeSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ProbeSelector}, - ProbeNamespaceSelector: &metav1.LabelSelector{MatchLabels: in.PrometheusCR.ProbeNamespaceSelector}, + PodMonitorSelector: &metav1.LabelSelector{ + MatchLabels: in.PrometheusCR.PodMonitorSelector, + }, + ServiceMonitorSelector: &metav1.LabelSelector{ + MatchLabels: in.PrometheusCR.ServiceMonitorSelector, + }, }, SecurityContext: in.SecurityContext, PodSecurityContext: in.PodSecurityContext, @@ -445,34 +441,10 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat if in.PrometheusCR.PodMonitorSelector != nil { podMonitorSelector = in.PrometheusCR.PodMonitorSelector.MatchLabels } - var podMonitorNamespaceSelector map[string]string - if in.PrometheusCR.PodMonitorNamespaceSelector != nil { - podMonitorNamespaceSelector = in.PrometheusCR.PodMonitorNamespaceSelector.MatchLabels - } var serviceMonitorSelector map[string]string if in.PrometheusCR.ServiceMonitorSelector != nil { serviceMonitorSelector = in.PrometheusCR.ServiceMonitorSelector.MatchLabels } - var serviceMonitorNamespaceSelector map[string]string - if in.PrometheusCR.ServiceMonitorNamespaceSelector != nil { - serviceMonitorNamespaceSelector = in.PrometheusCR.ServiceMonitorNamespaceSelector.MatchLabels - } - var scrapeConfigSelector map[string]string - if in.PrometheusCR.ScrapeConfigSelector != nil { - scrapeConfigSelector = in.PrometheusCR.ScrapeConfigSelector.MatchLabels - } - var scrapeConfigNamespaceSelector map[string]string - if in.PrometheusCR.ScrapeConfigNamespaceSelector != nil { - scrapeConfigNamespaceSelector = in.PrometheusCR.ScrapeConfigNamespaceSelector.MatchLabels - } - var probeSelector map[string]string - if in.PrometheusCR.ProbeSelector != nil { - probeSelector = in.PrometheusCR.ProbeSelector.MatchLabels - } - var probeNamespaceSelector map[string]string - if in.PrometheusCR.ProbeNamespaceSelector != nil { - probeNamespaceSelector = in.PrometheusCR.ProbeNamespaceSelector.MatchLabels - } return OpenTelemetryTargetAllocator{ Replicas: in.Replicas, @@ -485,19 +457,11 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat Enabled: in.Enabled, Affinity: in.Affinity, PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ - Enabled: in.PrometheusCR.Enabled, - ScrapeInterval: in.PrometheusCR.ScrapeInterval, - EvaluationInterval: in.PrometheusCR.EvaluationInterval, - ScrapeProtocols: in.PrometheusCR.ScrapeProtocols, - ScrapeClasses: in.PrometheusCR.ScrapeClasses, - PodMonitorSelector: podMonitorSelector, - PodMonitorNamespaceSelector: podMonitorNamespaceSelector, - ServiceMonitorSelector: serviceMonitorSelector, - ServiceMonitorNamespaceSelector: serviceMonitorNamespaceSelector, - ScrapeConfigSelector: scrapeConfigSelector, - ScrapeConfigNamespaceSelector: scrapeConfigNamespaceSelector, - ProbeSelector: probeSelector, - ProbeNamespaceSelector: probeNamespaceSelector, + Enabled: in.PrometheusCR.Enabled, + ScrapeInterval: in.PrometheusCR.ScrapeInterval, + ScrapeClasses: in.PrometheusCR.ScrapeClasses, + PodMonitorSelector: podMonitorSelector, + ServiceMonitorSelector: serviceMonitorSelector, }, SecurityContext: in.SecurityContext, PodSecurityContext: in.PodSecurityContext, diff --git a/apis/v1alpha1/convert_test.go b/apis/v1alpha1/convert_test.go index 809dbd698e..67f6ba60c7 100644 --- a/apis/v1alpha1/convert_test.go +++ b/apis/v1alpha1/convert_test.go @@ -358,14 +358,8 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { TargetAllocator: OpenTelemetryTargetAllocator{ PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ // nil or empty map means select everything - PodMonitorSelector: nil, - ServiceMonitorSelector: nil, - PodMonitorNamespaceSelector: nil, - ServiceMonitorNamespaceSelector: nil, - ScrapeConfigSelector: nil, - ScrapeConfigNamespaceSelector: nil, - ProbeSelector: nil, - ProbeNamespaceSelector: nil, + PodMonitorSelector: nil, + ServiceMonitorSelector: nil, }, }, }, @@ -379,32 +373,13 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { // empty LabelSelector mean select everything assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector)) assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector)) - assert.Equal(t, 0, len(colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector)) err = colalpha1.ConvertFrom(&colbeta1) require.NoError(t, err) assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) - assert.Nil(t, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) }) t.Run("empty-selectors", func(t *testing.T) { colalpha1 := OpenTelemetryCollector{ @@ -412,14 +387,8 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { TargetAllocator: OpenTelemetryTargetAllocator{ PrometheusCR: OpenTelemetryTargetAllocatorPrometheusCR{ // nil or empty map means select everything - PodMonitorSelector: map[string]string{}, - ServiceMonitorSelector: map[string]string{}, - PodMonitorNamespaceSelector: map[string]string{}, - ServiceMonitorNamespaceSelector: map[string]string{}, - ScrapeConfigSelector: map[string]string{}, - ScrapeConfigNamespaceSelector: map[string]string{}, - ProbeSelector: map[string]string{}, - ProbeNamespaceSelector: map[string]string{}, + PodMonitorSelector: map[string]string{}, + ServiceMonitorSelector: map[string]string{}, }, }, }, @@ -433,23 +402,11 @@ func Test_tov1beta1AndBack_prometheus_selectors(t *testing.T) { // empty LabelSelector mean select everything assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) - assert.NotNil(t, colbeta1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) err = colalpha1.ConvertFrom(&colbeta1) require.NoError(t, err) assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorSelector) assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.PodMonitorNamespaceSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ServiceMonitorNamespaceSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ScrapeConfigNamespaceSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeSelector) - assert.Equal(t, map[string]string{}, colalpha1.Spec.TargetAllocator.PrometheusCR.ProbeNamespaceSelector) }) } @@ -602,14 +559,8 @@ func TestConvertTo(t *testing.T) { }, TargetAllocator: v1beta1.TargetAllocatorEmbedded{ PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{ - PodMonitorSelector: &metav1.LabelSelector{}, - ServiceMonitorSelector: &metav1.LabelSelector{}, - PodMonitorNamespaceSelector: &metav1.LabelSelector{}, - ServiceMonitorNamespaceSelector: &metav1.LabelSelector{}, - ScrapeConfigSelector: &metav1.LabelSelector{}, - ScrapeConfigNamespaceSelector: &metav1.LabelSelector{}, - ProbeSelector: &metav1.LabelSelector{}, - ProbeNamespaceSelector: &metav1.LabelSelector{}, + PodMonitorSelector: &metav1.LabelSelector{}, + ServiceMonitorSelector: &metav1.LabelSelector{}, }, }, Config: v1beta1.Config{ diff --git a/apis/v1alpha1/opentelemetrycollector_types.go b/apis/v1alpha1/opentelemetrycollector_types.go index 5b25e0f3ba..bc579fd17d 100644 --- a/apis/v1alpha1/opentelemetrycollector_types.go +++ b/apis/v1alpha1/opentelemetrycollector_types.go @@ -385,29 +385,12 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct { // Enabled indicates whether to use a PrometheusOperator custom resources as targets or not. // +optional Enabled bool `json:"enabled,omitempty"` - // AllowNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (allow list). This is mutually exclusive with DenyNamespaces. - // +optional - AllowNamespaces []string `json:"allowNamespaces,omitempty"` - // DenyNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (deny list). This is mutually exclusive with AllowNamespaces. - // +optional - DenyNamespaces []string `json:"denyNamespaces,omitempty"` // Interval between consecutive scrapes. Equivalent to the same setting on the Prometheus CRD. // // Default: "30s" // +kubebuilder:default:="30s" // +kubebuilder:validation:Format:=duration ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"` - // Default interval between rule evaluations. - // - // Default: "30s" - // +kubebuilder:default:="30s" - // +kubebuilder:validation:Format:=duration - // +optional - EvaluationInterval *metav1.Duration `json:"evaluationInterval,omitempty"` - // ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the - // protocols supported by Prometheus in order of preference (from most to least preferred). - // +optional - ScrapeProtocols []string `json:"scrapeProtocols,omitempty"` // ScrapeClasses to be referenced by PodMonitors and ServiceMonitors to include common configuration. // If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass. // +optional @@ -420,48 +403,12 @@ type OpenTelemetryTargetAllocatorPrometheusCR struct { // Empty or nil map matches all pod monitors. // +optional PodMonitorSelector map[string]string `json:"podMonitorSelector,omitempty"` - // Namespaces to be selected for PodMonitor discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // namespace's meta labels. The requirements are ANDed. - // Empty or nil map matches all namespaces. - // +optional - PodMonitorNamespaceSelector map[string]string `json:"podMonitorNamespaceSelector,omitempty"` // ServiceMonitors to be selected for target discovery. // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a // ServiceMonitor's meta labels. The requirements are ANDed. // Empty or nil map matches all service monitors. // +optional ServiceMonitorSelector map[string]string `json:"serviceMonitorSelector,omitempty"` - // Namespaces to be selected for ServiceMonitor discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // namespace's meta labels. The requirements are ANDed. - // Empty or nil map matches all namespaces. - // +optional - ServiceMonitorNamespaceSelector map[string]string `json:"serviceMonitorNamespaceSelector,omitempty"` - // ScrapeConfigs to be selected for target discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // ScrapeConfig's meta labels. The requirements are ANDed. - // Empty or nil map matches all scrape configs. - // +optional - ScrapeConfigSelector map[string]string `json:"scrapeConfigSelector,omitempty"` - // Namespaces to be selected for ScrapeConfig discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // namespace's meta labels. The requirements are ANDed. - // Empty or nil map matches all namespaces. - // +optional - ScrapeConfigNamespaceSelector map[string]string `json:"scrapeConfigNamespaceSelector,omitempty"` - // Probes to be selected for target discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // Probe's meta labels. The requirements are ANDed. - // Empty or nil map matches all probes. - // +optional - ProbeSelector map[string]string `json:"probeSelector,omitempty"` - // Namespaces to be selected for Probe discovery. - // This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a - // namespace's meta labels. The requirements are ANDed. - // Empty or nil map matches all namespaces. - // +optional - ProbeNamespaceSelector map[string]string `json:"probeNamespaceSelector,omitempty"` } // ScaleSubresourceStatus defines the observed state of the OpenTelemetryCollector's diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index c5ee589e1d..20820c075f 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -1297,31 +1297,11 @@ func (in *OpenTelemetryTargetAllocator) DeepCopy() *OpenTelemetryTargetAllocator // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTelemetryTargetAllocatorPrometheusCR) { *out = *in - if in.AllowNamespaces != nil { - in, out := &in.AllowNamespaces, &out.AllowNamespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.DenyNamespaces != nil { - in, out := &in.DenyNamespaces, &out.DenyNamespaces - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.ScrapeInterval != nil { in, out := &in.ScrapeInterval, &out.ScrapeInterval *out = new(metav1.Duration) **out = **in } - if in.EvaluationInterval != nil { - in, out := &in.EvaluationInterval, &out.EvaluationInterval - *out = new(metav1.Duration) - **out = **in - } - if in.ScrapeProtocols != nil { - in, out := &in.ScrapeProtocols, &out.ScrapeProtocols - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.ScrapeClasses != nil { in, out := &in.ScrapeClasses, &out.ScrapeClasses *out = make([]v1beta1.AnyConfig, len(*in)) @@ -1336,13 +1316,6 @@ func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTeleme (*out)[key] = val } } - if in.PodMonitorNamespaceSelector != nil { - in, out := &in.PodMonitorNamespaceSelector, &out.PodMonitorNamespaceSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } if in.ServiceMonitorSelector != nil { in, out := &in.ServiceMonitorSelector, &out.ServiceMonitorSelector *out = make(map[string]string, len(*in)) @@ -1350,41 +1323,6 @@ func (in *OpenTelemetryTargetAllocatorPrometheusCR) DeepCopyInto(out *OpenTeleme (*out)[key] = val } } - if in.ServiceMonitorNamespaceSelector != nil { - in, out := &in.ServiceMonitorNamespaceSelector, &out.ServiceMonitorNamespaceSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ScrapeConfigSelector != nil { - in, out := &in.ScrapeConfigSelector, &out.ScrapeConfigSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ScrapeConfigNamespaceSelector != nil { - in, out := &in.ScrapeConfigNamespaceSelector, &out.ScrapeConfigNamespaceSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ProbeSelector != nil { - in, out := &in.ProbeSelector, &out.ProbeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ProbeNamespaceSelector != nil { - in, out := &in.ProbeNamespaceSelector, &out.ProbeNamespaceSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenTelemetryTargetAllocatorPrometheusCR. diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index 6cde2bc348..af8b6a9ced 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-24T09:23:18Z" + createdAt: "2026-02-24T15:04:26Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 3af55ecc13..4c665cf678 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3363,62 +3363,22 @@ spec: type: object prometheusCR: properties: - allowNamespaces: - items: - type: string - type: array - denyNamespaces: - items: - type: string - type: array enabled: type: boolean - evaluationInterval: - default: 30s - format: duration - type: string - podMonitorNamespaceSelector: - additionalProperties: - type: string - type: object podMonitorSelector: additionalProperties: type: string type: object - probeNamespaceSelector: - additionalProperties: - type: string - type: object - probeSelector: - additionalProperties: - type: string - type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true - scrapeConfigNamespaceSelector: - additionalProperties: - type: string - type: object - scrapeConfigSelector: - additionalProperties: - type: string - type: object scrapeInterval: default: 30s format: duration type: string - scrapeProtocols: - items: - type: string - type: array - serviceMonitorNamespaceSelector: - additionalProperties: - type: string - type: object serviceMonitorSelector: additionalProperties: type: string diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index 1bb25c3ed9..b8fd78cce0 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-24T09:23:18Z" + createdAt: "2026-02-24T15:04:26Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 7e6dd92870..fbeabf342f 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -3362,62 +3362,22 @@ spec: type: object prometheusCR: properties: - allowNamespaces: - items: - type: string - type: array - denyNamespaces: - items: - type: string - type: array enabled: type: boolean - evaluationInterval: - default: 30s - format: duration - type: string - podMonitorNamespaceSelector: - additionalProperties: - type: string - type: object podMonitorSelector: additionalProperties: type: string type: object - probeNamespaceSelector: - additionalProperties: - type: string - type: object - probeSelector: - additionalProperties: - type: string - type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true - scrapeConfigNamespaceSelector: - additionalProperties: - type: string - type: object - scrapeConfigSelector: - additionalProperties: - type: string - type: object scrapeInterval: default: 30s format: duration type: string - scrapeProtocols: - items: - type: string - type: array - serviceMonitorNamespaceSelector: - additionalProperties: - type: string - type: object serviceMonitorSelector: additionalProperties: type: string diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 2d222aa911..671ddd9cd3 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -3349,62 +3349,22 @@ spec: type: object prometheusCR: properties: - allowNamespaces: - items: - type: string - type: array - denyNamespaces: - items: - type: string - type: array enabled: type: boolean - evaluationInterval: - default: 30s - format: duration - type: string - podMonitorNamespaceSelector: - additionalProperties: - type: string - type: object podMonitorSelector: additionalProperties: type: string type: object - probeNamespaceSelector: - additionalProperties: - type: string - type: object - probeSelector: - additionalProperties: - type: string - type: object scrapeClasses: items: type: object type: array x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true - scrapeConfigNamespaceSelector: - additionalProperties: - type: string - type: object - scrapeConfigSelector: - additionalProperties: - type: string - type: object scrapeInterval: default: 30s format: duration type: string - scrapeProtocols: - items: - type: string - type: array - serviceMonitorNamespaceSelector: - additionalProperties: - type: string - type: object serviceMonitorSelector: additionalProperties: type: string diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index 62734f5a0d..2a6abb1644 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -13975,48 +13975,12 @@ All CR instances which the ServiceAccount has access to will be retrieved. This - allowNamespaces - []string - - AllowNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (allow list). This is mutually exclusive with DenyNamespaces.
- - false - - denyNamespaces - []string - - DenyNamespaces Namespaces to scope the interaction of the Target Allocator and the apiserver (deny list). This is mutually exclusive with AllowNamespaces.
- - false - enabled boolean Enabled indicates whether to use a PrometheusOperator custom resources as targets or not.
false - - evaluationInterval - string - - Default interval between rule evaluations. - -Default: "30s"
-
- Format: duration
- Default: 30s
- - false - - podMonitorNamespaceSelector - map[string]string - - Namespaces to be selected for PodMonitor discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -namespace's meta labels. The requirements are ANDed. -Empty or nil map matches all namespaces.
- - false podMonitorSelector map[string]string @@ -14027,26 +13991,6 @@ PodMonitor's meta labels. The requirements are ANDed. Empty or nil map matches all pod monitors.
false - - probeNamespaceSelector - map[string]string - - Namespaces to be selected for Probe discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -namespace's meta labels. The requirements are ANDed. -Empty or nil map matches all namespaces.
- - false - - probeSelector - map[string]string - - Probes to be selected for target discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -Probe's meta labels. The requirements are ANDed. -Empty or nil map matches all probes.
- - false scrapeClasses []object @@ -14055,26 +13999,6 @@ Empty or nil map matches all probes.
If specified, expects an array of ScrapeClass objects as specified by https://prometheus-operator.dev/docs/api-reference/api/#monitoring.coreos.com/v1.ScrapeClass.
false - - scrapeConfigNamespaceSelector - map[string]string - - Namespaces to be selected for ScrapeConfig discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -namespace's meta labels. The requirements are ANDed. -Empty or nil map matches all namespaces.
- - false - - scrapeConfigSelector - map[string]string - - ScrapeConfigs to be selected for target discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -ScrapeConfig's meta labels. The requirements are ANDed. -Empty or nil map matches all scrape configs.
- - false scrapeInterval string @@ -14087,24 +14011,6 @@ Default: "30s"
Default: 30s
false - - scrapeProtocols - []string - - ScrapeProtocols define the protocols to negotiate during a scrape. It tells clients the -protocols supported by Prometheus in order of preference (from most to least preferred).
- - false - - serviceMonitorNamespaceSelector - map[string]string - - Namespaces to be selected for ServiceMonitor discovery. -This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a -namespace's meta labels. The requirements are ANDed. -Empty or nil map matches all namespaces.
- - false serviceMonitorSelector map[string]string From 7e4504e682283022327f97df1355ab3fc04fad71 Mon Sep 17 00:00:00 2001 From: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> Date: Wed, 25 Feb 2026 09:18:48 +0100 Subject: [PATCH 3/5] refactor: address reviewer feedback for Prometheus CR selectors Signed-off-by: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> --- apis/v1beta1/targetallocator_types.go | 4 + ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 4 + .../opentelemetry.io_targetallocators.yaml | 4 + ...emetry-operator.clusterserviceversion.yaml | 2 +- ...ntelemetry.io_opentelemetrycollectors.yaml | 4 + .../opentelemetry.io_targetallocators.yaml | 4 + ...ntelemetry.io_opentelemetrycollectors.yaml | 4 + .../opentelemetry.io_targetallocators.yaml | 4 + docs/api/opentelemetrycollectors.md | 8 ++ docs/api/targetallocators.md | 8 ++ internal/controllers/builder_test.go | 32 ++++-- .../manifests/targetallocator/configmap.go | 16 +-- .../targetallocator/configmap_test.go | 105 +++++++++++++++++- .../02-assert.yaml | 10 +- .../03-assert.yaml | 10 ++ .../03-install.yaml | 23 ++++ .../chainsaw-test.yaml | 6 + 18 files changed, 222 insertions(+), 28 deletions(-) create mode 100644 tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml create mode 100644 tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml diff --git a/apis/v1beta1/targetallocator_types.go b/apis/v1beta1/targetallocator_types.go index 80963d2edc..2f5253e467 100644 --- a/apis/v1beta1/targetallocator_types.go +++ b/apis/v1beta1/targetallocator_types.go @@ -52,6 +52,7 @@ type TargetAllocatorPrometheusCR struct { // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional + // +kubebuilder:default:={} PodMonitorNamespaceSelector *metav1.LabelSelector `json:"podMonitorNamespaceSelector,omitempty"` // ServiceMonitors to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and @@ -64,6 +65,7 @@ type TargetAllocatorPrometheusCR struct { // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional + // +kubebuilder:default:={} ServiceMonitorNamespaceSelector *metav1.LabelSelector `json:"serviceMonitorNamespaceSelector,omitempty"` // ScrapeConfigs to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and @@ -76,6 +78,7 @@ type TargetAllocatorPrometheusCR struct { // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional + // +kubebuilder:default:={} ScrapeConfigNamespaceSelector *metav1.LabelSelector `json:"scrapeConfigNamespaceSelector,omitempty"` // Probes to be selected for target discovery. // A label selector is a label query over a set of resources. The result of matchLabels and @@ -88,6 +91,7 @@ type TargetAllocatorPrometheusCR struct { // matchExpressions are ANDed. An empty label selector matches all objects. A null // label selector matches no objects. // +optional + // +kubebuilder:default:={} ProbeNamespaceSelector *metav1.LabelSelector `json:"probeNamespaceSelector,omitempty"` } diff --git a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml index af8b6a9ced..23371023f4 100644 --- a/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-24T15:04:26Z" + createdAt: "2026-02-25T08:17:14Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml index 4c665cf678..a31223739d 100644 --- a/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -8271,6 +8271,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8323,6 +8324,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8381,6 +8383,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8441,6 +8444,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml index 0f1e3f1144..da5e64c30a 100644 --- a/bundle/community/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/community/manifests/opentelemetry.io_targetallocators.yaml @@ -2474,6 +2474,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2526,6 +2527,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2584,6 +2586,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2644,6 +2647,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml index b8fd78cce0..bba0cf93b7 100644 --- a/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml +++ b/bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml @@ -99,7 +99,7 @@ metadata: categories: Logging & Tracing,Monitoring,Observability certified: "false" containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - createdAt: "2026-02-24T15:04:26Z" + createdAt: "2026-02-25T08:17:14Z" description: Provides the OpenTelemetry components, including the Collector operators.operatorframework.io/builder: operator-sdk-v1.29.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml index fbeabf342f..40641058b2 100644 --- a/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml @@ -8270,6 +8270,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8322,6 +8323,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8380,6 +8382,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8440,6 +8443,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml index 0f1e3f1144..da5e64c30a 100644 --- a/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml +++ b/bundle/openshift/manifests/opentelemetry.io_targetallocators.yaml @@ -2474,6 +2474,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2526,6 +2527,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2584,6 +2586,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2644,6 +2647,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml index 671ddd9cd3..4c51ba6bac 100644 --- a/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml +++ b/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml @@ -8257,6 +8257,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8309,6 +8310,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8367,6 +8369,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -8427,6 +8430,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/config/crd/bases/opentelemetry.io_targetallocators.yaml b/config/crd/bases/opentelemetry.io_targetallocators.yaml index 8a9a25ffd3..46d5cb71f5 100644 --- a/config/crd/bases/opentelemetry.io_targetallocators.yaml +++ b/config/crd/bases/opentelemetry.io_targetallocators.yaml @@ -2472,6 +2472,7 @@ spec: format: duration type: string podMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2524,6 +2525,7 @@ spec: type: object x-kubernetes-map-type: atomic probeNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2582,6 +2584,7 @@ spec: x-kubernetes-list-type: atomic x-kubernetes-preserve-unknown-fields: true scrapeConfigNamespaceSelector: + default: {} properties: matchExpressions: items: @@ -2642,6 +2645,7 @@ spec: type: string type: array serviceMonitorNamespaceSelector: + default: {} properties: matchExpressions: items: diff --git a/docs/api/opentelemetrycollectors.md b/docs/api/opentelemetrycollectors.md index 2a6abb1644..ac3329da10 100644 --- a/docs/api/opentelemetrycollectors.md +++ b/docs/api/opentelemetrycollectors.md @@ -34742,6 +34742,8 @@ Default: "30s"
A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -34762,6 +34764,8 @@ label selector matches no objects.
A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -34790,6 +34794,8 @@ If specified, expects an array of ScrapeClass objects as specified by https://pr A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -34830,6 +34836,8 @@ protocols supported by Prometheus in order of preference (from most to least pre A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false diff --git a/docs/api/targetallocators.md b/docs/api/targetallocators.md index e8bc81c4f8..3840a454d1 100644 --- a/docs/api/targetallocators.md +++ b/docs/api/targetallocators.md @@ -10346,6 +10346,8 @@ Default: "30s"
A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -10366,6 +10368,8 @@ label selector matches no objects.
A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -10394,6 +10398,8 @@ If specified, expects an array of ScrapeClass objects as specified by https://pr A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false @@ -10434,6 +10440,8 @@ protocols supported by Prometheus in order of preference (from most to least pre A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
+
+ Default: map[]
false diff --git a/internal/controllers/builder_test.go b/internal/controllers/builder_test.go index 3f60bde263..c24b80974b 100644 --- a/internal/controllers/builder_test.go +++ b/internal/controllers/builder_test.go @@ -1974,9 +1974,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2010,7 +2014,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: corev1.PodSpec{ @@ -2160,7 +2164,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2273,9 +2277,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2309,7 +2317,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: corev1.PodSpec{ @@ -2459,7 +2467,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "f80c054419fe2f9030368557da143e200c70772d1d5f1be50ed55ae960b4b17d", + "opentelemetry-targetallocator-config/hash": "7a839fe32950e427672bf7038e88d953ceecf1531457af7c43dc78300dc85eca", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2622,9 +2630,13 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2658,7 +2670,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", + "opentelemetry-targetallocator-config/hash": "a81383bc4e7ebbf141d2fd9cde3dcd9758bc47f27af6cbaeb0f14ab6360e08c6", }, }, Spec: corev1.PodSpec{ @@ -2808,7 +2820,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "286a5a4e7ec6d2ce652a4ce23e135c10053b4c87fd080242daa5bf21dcd5a337", + "opentelemetry-targetallocator-config/hash": "a81383bc4e7ebbf141d2fd9cde3dcd9758bc47f27af6cbaeb0f14ab6360e08c6", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ @@ -2945,9 +2957,13 @@ https: tls_key_file_path: /tls/tls.key prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, }, @@ -2981,7 +2997,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", + "opentelemetry-targetallocator-config/hash": "02ef308f21c5312c388985bd8ca91246d1df7a3a5031135ec176f3c975e2fa37", }, }, Spec: corev1.PodSpec{ @@ -3157,7 +3173,7 @@ prometheus_cr: "app.kubernetes.io/version": "latest", }, Annotations: map[string]string{ - "opentelemetry-targetallocator-config/hash": "3e2818ab54d866289de7837779e86e9c95803c43c0c4b58b25123e809ae9b771", + "opentelemetry-targetallocator-config/hash": "02ef308f21c5312c388985bd8ca91246d1df7a3a5031135ec176f3c975e2fa37", }, }, Spec: policyV1.PodDisruptionBudgetSpec{ diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index feccf099fa..73a1f7e6d0 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -112,25 +112,17 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { prometheusCRConfig["deny_namespaces"] = taSpec.PrometheusCR.DenyNamespaces } + prometheusCRConfig["service_monitor_namespace_selector"] = taSpec.PrometheusCR.ServiceMonitorNamespaceSelector prometheusCRConfig["service_monitor_selector"] = taSpec.PrometheusCR.ServiceMonitorSelector - if taSpec.PrometheusCR.ServiceMonitorNamespaceSelector != nil { - prometheusCRConfig["service_monitor_namespace_selector"] = taSpec.PrometheusCR.ServiceMonitorNamespaceSelector - } + prometheusCRConfig["pod_monitor_namespace_selector"] = taSpec.PrometheusCR.PodMonitorNamespaceSelector prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector - if taSpec.PrometheusCR.PodMonitorNamespaceSelector != nil { - prometheusCRConfig["pod_monitor_namespace_selector"] = taSpec.PrometheusCR.PodMonitorNamespaceSelector - } + prometheusCRConfig["scrape_config_namespace_selector"] = taSpec.PrometheusCR.ScrapeConfigNamespaceSelector prometheusCRConfig["scrape_config_selector"] = taSpec.PrometheusCR.ScrapeConfigSelector - if taSpec.PrometheusCR.ScrapeConfigNamespaceSelector != nil { - prometheusCRConfig["scrape_config_namespace_selector"] = taSpec.PrometheusCR.ScrapeConfigNamespaceSelector - } + prometheusCRConfig["probe_namespace_selector"] = taSpec.PrometheusCR.ProbeNamespaceSelector prometheusCRConfig["probe_selector"] = taSpec.PrometheusCR.ProbeSelector - if taSpec.PrometheusCR.ProbeNamespaceSelector != nil { - prometheusCRConfig["probe_namespace_selector"] = taSpec.PrometheusCR.ProbeNamespaceSelector - } taConfig["prometheus_cr"] = prometheusCRConfig } diff --git a/internal/manifests/targetallocator/configmap_test.go b/internal/manifests/targetallocator/configmap_test.go index 5fac38a71a..b0d7117235 100644 --- a/internal/manifests/targetallocator/configmap_test.go +++ b/internal/manifests/targetallocator/configmap_test.go @@ -146,18 +146,22 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: matchlabels: release: my-instance matchexpressions: [] + probe_namespace_selector: null probe_selector: matchlabels: release: my-instance matchexpressions: [] + scrape_config_namespace_selector: null scrape_config_selector: matchlabels: release: my-instance matchexpressions: [] + service_monitor_namespace_selector: null service_monitor_selector: matchlabels: release: my-instance @@ -198,9 +202,95 @@ prometheus_cr: assert.Equal(t, "my-instance-targetallocator", actual.Name) assert.Equal(t, expectedLabels, actual.Labels) assert.Equal(t, expectedData, actual.Data) + }) + t.Run("should return expected target allocator config map with namespace label selectors", func(t *testing.T) { + expectedData := map[string]string{ + targetAllocatorFilename: `allocation_strategy: consistent-hashing +collector_selector: + matchlabels: + app.kubernetes.io/component: opentelemetry-collector + app.kubernetes.io/instance: default.my-instance + app.kubernetes.io/managed-by: opentelemetry-operator + app.kubernetes.io/part-of: opentelemetry + matchexpressions: [] +config: + global: + scrape_interval: 30s + scrape_protocols: + - PrometheusProto + - OpenMetricsText1.0.0 + - OpenMetricsText0.0.1 + - PrometheusText0.0.4 + scrape_configs: + - job_name: otel-collector + scrape_interval: 10s + static_configs: + - targets: + - 0.0.0.0:8888 + - 0.0.0.0:9999 +filter_strategy: relabel-config +prometheus_cr: + enabled: true + pod_monitor_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + pod_monitor_selector: null + probe_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + probe_selector: null + scrape_config_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + scrape_config_selector: null + service_monitor_namespace_selector: + matchlabels: + release: my-instance + matchexpressions: [] + service_monitor_selector: null +`, + } + targetAllocator := targetAllocatorInstance() + targetAllocator.Spec.PrometheusCR.Enabled = true + targetAllocator.Spec.PrometheusCR.PodMonitorNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }, + } + targetAllocator.Spec.PrometheusCR.ServiceMonitorNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ScrapeConfigNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.PrometheusCR.ProbeNamespaceSelector = &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "release": "my-instance", + }} + targetAllocator.Spec.GlobalConfig = v1beta1.AnyConfig{ + Object: map[string]any{ + "scrape_interval": "30s", + "scrape_protocols": []string{"PrometheusProto", "OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText0.0.4"}, + }, + } + testParams := Params{ + Collector: collectorInstance(), + TargetAllocator: targetAllocator, + } + actual, err := ConfigMap(testParams) + assert.NoError(t, err) + assert.Equal(t, "my-instance-targetallocator", actual.Name) + assert.Equal(t, expectedLabels, actual.Labels) + assert.Equal(t, expectedData, actual.Data) }) - t.Run("should return expected target allocator config map with scrape interval set", func(t *testing.T) { + + t.Run("should return expected target allocator config map with scrape and evaluation intervals and protocols set", func(t *testing.T) { expectedData := map[string]string{ targetAllocatorFilename: `allocation_strategy: consistent-hashing collector_selector: @@ -221,10 +311,17 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + evaluation_interval: 30s + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null + scrape_config_namespace_selector: null scrape_config_selector: null scrape_interval: 30s + scrape_protocols: + - PrometheusText1.0.0 + service_monitor_namespace_selector: null service_monitor_selector: null `, } @@ -232,6 +329,8 @@ prometheus_cr: targetAllocator := targetAllocatorInstance() targetAllocator.Spec.PrometheusCR.Enabled = true targetAllocator.Spec.PrometheusCR.ScrapeInterval = &metav1.Duration{Duration: time.Second * 30} + targetAllocator.Spec.PrometheusCR.EvaluationInterval = &metav1.Duration{Duration: time.Second * 30} + targetAllocator.Spec.PrometheusCR.ScrapeProtocols = []string{"PrometheusText1.0.0"} testParams := Params{ Collector: collectorInstance(), TargetAllocator: targetAllocator, @@ -266,7 +365,9 @@ config: filter_strategy: relabel-config prometheus_cr: enabled: true + pod_monitor_namespace_selector: null pod_monitor_selector: null + probe_namespace_selector: null probe_selector: null scrape_classes: - default: true @@ -274,7 +375,9 @@ prometheus_cr: relabelings: - action: labeldrop regex: pod + scrape_config_namespace_selector: null scrape_config_selector: null + service_monitor_namespace_selector: null service_monitor_selector: null `, } diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml index ccedd3aff6..3cdee51be9 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -24,16 +24,16 @@ data: ( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false ( contains(@, join(':', ['matchlabels', ' {}}'])) ): false ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false - ( contains(@, 'evaluation_interval: 2m') ): true + ( contains(@, join(':', ['evaluation_interval', ' 2m'])) ): true ( contains(@, '- PrometheusText1.0.0') ): true ( contains(@, 'service_monitor_namespace_selector:') ): true ( contains(@, 'pod_monitor_namespace_selector:') ): true ( contains(@, 'scrape_config_namespace_selector:') ): true ( contains(@, 'probe_namespace_selector:') ): true - ( contains(@, 'ns-label: service') ): true - ( contains(@, 'ns-label: pod') ): true - ( contains(@, 'ns-label: scrape') ): true - ( contains(@, 'ns-label: probe') ): true + ( contains(@, join(':', ['ns-label', ' service'])) ): true + ( contains(@, join(':', ['ns-label', ' pod'])) ): true + ( contains(@, join(':', ['ns-label', ' scrape'])) ): true + ( contains(@, join(':', ['ns-label', ' probe'])) ): true kind: ConfigMap metadata: name: prometheus-cr-v1beta1-targetallocator diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml new file mode 100644 index 0000000000..c1709a7e05 --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + targetallocator.yaml: + ( contains(@, join(':', ['pod_monitor_namespace_selector', ' {}'])) ): true + ( contains(@, join(':', ['service_monitor_namespace_selector', ' {}'])) ): true + ( contains(@, join(':', ['scrape_config_namespace_selector', ' {}'])) ): true + ( contains(@, join(':', ['probe_namespace_selector', ' {}'])) ): true +kind: ConfigMap +metadata: + name: prometheus-cr-v1beta1-ns-defaults-targetallocator diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml new file mode 100644 index 0000000000..44e408f48b --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: prometheus-cr-v1beta1-ns-defaults +spec: + config: + receivers: + prometheus: + config: + scrape_configs: [] + exporters: + debug: {} + service: + pipelines: + metrics: + receivers: [prometheus] + exporters: [debug] + mode: statefulset + targetAllocator: + enabled: true + prometheusCR: + enabled: true diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index 280d656819..7d5cf45629 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -40,3 +40,9 @@ spec: catch: - podLogs: selector: checker=true + - name: step-03 + try: + - apply: + file: 03-install.yaml + - assert: + file: 03-assert.yaml From 100ee8a6d0a697b5f30be37870cb30e753601e07 Mon Sep 17 00:00:00 2001 From: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> Date: Wed, 25 Feb 2026 20:22:14 +0100 Subject: [PATCH 4/5] fix: Update TA Prometheus CR e2e namespace discovery tests Signed-off-by: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> --- .../02-assert.yaml | 8 ++- .../02-install.yaml | 12 ----- .../03-assert.yaml | 20 ++++--- .../03-install.yaml | 52 +++++++++++++++++-- .../chainsaw-test.yaml | 2 + 5 files changed, 68 insertions(+), 26 deletions(-) diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml index 3cdee51be9..ff63a5f5e6 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -26,14 +26,12 @@ data: ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false ( contains(@, join(':', ['evaluation_interval', ' 2m'])) ): true ( contains(@, '- PrometheusText1.0.0') ): true - ( contains(@, 'service_monitor_namespace_selector:') ): true ( contains(@, 'pod_monitor_namespace_selector:') ): true + ( contains(@, 'service_monitor_namespace_selector:') ): true ( contains(@, 'scrape_config_namespace_selector:') ): true ( contains(@, 'probe_namespace_selector:') ): true - ( contains(@, join(':', ['ns-label', ' service'])) ): true - ( contains(@, join(':', ['ns-label', ' pod'])) ): true - ( contains(@, join(':', ['ns-label', ' scrape'])) ): true - ( contains(@, join(':', ['ns-label', ' probe'])) ): true + ( contains(@, join(':', ['matchlabels', ' {}'])) ): true + ( contains(@, join(':', ['matchexpressions', ' []'])) ): true kind: ConfigMap metadata: name: prometheus-cr-v1beta1-targetallocator diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml index 8584dbbf20..bbef13af95 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml @@ -32,18 +32,6 @@ spec: - PrometheusText1.0.0 scrapeConfigSelector: {} probeSelector: {} - podMonitorNamespaceSelector: - matchLabels: - ns-label: pod - serviceMonitorNamespaceSelector: - matchLabels: - ns-label: service - scrapeConfigNamespaceSelector: - matchLabels: - ns-label: scrape - probeNamespaceSelector: - matchLabels: - ns-label: probe scrapeClasses: - name: tls-config tlsConfig: diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml index c1709a7e05..63146d5f11 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-assert.yaml @@ -1,10 +1,18 @@ apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-cr-ns-discovery-v1beta1-targetallocator data: targetallocator.yaml: - ( contains(@, join(':', ['pod_monitor_namespace_selector', ' {}'])) ): true - ( contains(@, join(':', ['service_monitor_namespace_selector', ' {}'])) ): true - ( contains(@, join(':', ['scrape_config_namespace_selector', ' {}'])) ): true - ( contains(@, join(':', ['probe_namespace_selector', ' {}'])) ): true -kind: ConfigMap + ( contains(@, 'pod_monitor_namespace_selector:') ): true + ( contains(@, 'service_monitor_namespace_selector:') ): true + ( contains(@, 'scrape_config_namespace_selector:') ): true + ( contains(@, 'probe_namespace_selector:') ): true + ( contains(@, join(':', ['ns-label', ' targetallocator-e2e'])) ): true +--- +apiVersion: batch/v1 +kind: Job metadata: - name: prometheus-cr-v1beta1-ns-defaults-targetallocator + name: check-ta-ns-discovery-v1beta1 +status: + succeeded: 1 diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml index 44e408f48b..faffd2330e 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/03-install.yaml @@ -2,22 +2,68 @@ apiVersion: opentelemetry.io/v1beta1 kind: OpenTelemetryCollector metadata: - name: prometheus-cr-v1beta1-ns-defaults + name: prometheus-cr-ns-discovery-v1beta1 spec: config: receivers: prometheus: config: scrape_configs: [] + + processors: + exporters: - debug: {} + prometheus: + endpoint: 0.0.0.0:9090 service: pipelines: metrics: receivers: [prometheus] - exporters: [debug] + exporters: [prometheus] mode: statefulset + serviceAccount: collector targetAllocator: enabled: true + serviceAccount: ta prometheusCR: enabled: true + scrapeConfigSelector: {} + podMonitorNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + serviceMonitorNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + scrapeConfigNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e + probeNamespaceSelector: + matchLabels: + ns-label: targetallocator-e2e +--- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: ScrapeConfig +metadata: + name: ns-discovery-scrape-config-cr +spec: + kubernetesSDConfigs: + - role: Node +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ta-ns-discovery-v1beta1 +spec: + template: + metadata: + labels: + checker: "true" + spec: + restartPolicy: OnFailure + containers: + - name: check-metrics + image: docker.io/curlimages/curl:latest + args: + - /bin/sh + - -c + - curl -s http://prometheus-cr-ns-discovery-v1beta1-targetallocator/scrape_configs | grep "ns-discovery-scrape-config-cr" diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index 7d5cf45629..7190cbd874 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -42,6 +42,8 @@ spec: selector: checker=true - name: step-03 try: + - script: + content: kubectl label namespace $NAMESPACE ns-label=targetallocator-e2e - apply: file: 03-install.yaml - assert: From bb315ad726d8c192c017f176628a1a8b8d528902 Mon Sep 17 00:00:00 2001 From: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:32:07 +0100 Subject: [PATCH 5/5] fix add prometheus_cr namespace selectors Signed-off-by: Alexander Soelberg Heidarsson <89837986+alex5517@users.noreply.github.com> --- tests/e2e-targetallocator-cr/01-assert.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/e2e-targetallocator-cr/01-assert.yaml b/tests/e2e-targetallocator-cr/01-assert.yaml index 441308f4ec..3c5c15aee1 100644 --- a/tests/e2e-targetallocator-cr/01-assert.yaml +++ b/tests/e2e-targetallocator-cr/01-assert.yaml @@ -95,10 +95,23 @@ data: filter_strategy: relabel-config prometheus_cr: enabled: true + evaluation_interval: 30s + pod_monitor_namespace_selector: + matchlabels: {} + matchexpressions: [] pod_monitor_selector: null + probe_namespace_selector: + matchlabels: {} + matchexpressions: [] probe_selector: null + scrape_config_namespace_selector: + matchlabels: {} + matchexpressions: [] scrape_config_selector: null scrape_interval: 30s + service_monitor_namespace_selector: + matchlabels: {} + matchexpressions: [] service_monitor_selector: null kind: ConfigMap metadata: