From 355cd36130493d5d9960b32abdd11cb14cef9a19 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Fri, 28 Nov 2025 10:44:08 +0100 Subject: [PATCH] change: add new arguments to manifests This commit adds the following arguments in jsonnet + default manifests: * `--watch-referenced-objects-in-all-namespaces=true` * `--disable-unmanaged-prometheus-configuration=true` Signed-off-by: Simon Pasquier --- bundle.yaml | 2 + .../prometheus-operator-deployment.yaml | 2 + .../prometheus-operator.libsonnet | 2 + test/e2e/main_test.go | 2 - test/e2e/prometheus_test.go | 83 +++++++------------ 5 files changed, 37 insertions(+), 54 deletions(-) diff --git a/bundle.yaml b/bundle.yaml index f16db3feb..b82a1f6cb 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -74004,6 +74004,8 @@ spec: - args: - --kubelet-service=kube-system/kubelet - --prometheus-config-reloader=quay.io/prometheus-operator/prometheus-config-reloader:v0.87.0 + - --watch-referenced-objects-in-all-namespaces=true + - --disable-unmanaged-prometheus-configuration=true - --kubelet-endpoints=true - --kubelet-endpointslice=false env: diff --git a/example/rbac/prometheus-operator/prometheus-operator-deployment.yaml b/example/rbac/prometheus-operator/prometheus-operator-deployment.yaml index 11097db33..4fbeebed7 100644 --- a/example/rbac/prometheus-operator/prometheus-operator-deployment.yaml +++ b/example/rbac/prometheus-operator/prometheus-operator-deployment.yaml @@ -27,6 +27,8 @@ spec: - args: - --kubelet-service=kube-system/kubelet - --prometheus-config-reloader=quay.io/prometheus-operator/prometheus-config-reloader:v0.87.0 + - --watch-referenced-objects-in-all-namespaces=true + - --disable-unmanaged-prometheus-configuration=true - --kubelet-endpoints=true - --kubelet-endpointslice=false env: diff --git a/jsonnet/prometheus-operator/prometheus-operator.libsonnet b/jsonnet/prometheus-operator/prometheus-operator.libsonnet index 46d2adb6b..3dece63ef 100644 --- a/jsonnet/prometheus-operator/prometheus-operator.libsonnet +++ b/jsonnet/prometheus-operator/prometheus-operator.libsonnet @@ -197,6 +197,8 @@ function(params) { args: [ '--kubelet-service=' + po.config.kubeletService, '--prometheus-config-reloader=' + po.config.configReloaderImage, + '--watch-referenced-objects-in-all-namespaces=true', + '--disable-unmanaged-prometheus-configuration=true', ] + [std.format('--kubelet-endpoints=%s', po.config.kubeletEndpointsEnabled)] + [std.format('--kubelet-endpointslice=%s', po.config.kubeletEndpointSliceEnabled)] + diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index ead06f608..19c95e134 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -180,8 +180,6 @@ func TestAllNS(t *testing.T) { EnableAdmissionWebhook: true, ClusterRoleBindings: true, EnableScrapeConfigs: true, - // testPrometheusReconciliationOnSecretChanges needs this flag to be turned on. - AdditionalArgs: []string{"--watch-referenced-objects-in-all-namespaces=true"}, }, ) require.NoError(t, err) diff --git a/test/e2e/prometheus_test.go b/test/e2e/prometheus_test.go index f9e7a9289..8fdb7e000 100644 --- a/test/e2e/prometheus_test.go +++ b/test/e2e/prometheus_test.go @@ -1146,38 +1146,33 @@ func testPromReloadConfig(t *testing.T) { p := framework.MakeBasicPrometheus(ns, name, name, 1) p.Spec.ServiceMonitorSelector = nil p.Spec.PodMonitorSelector = nil + p.Spec.AdditionalScrapeConfigs = &v1.SecretKeySelector{ + LocalObjectReference: v1.LocalObjectReference{ + Name: fmt.Sprintf("additional-config-%s", name), + }, + Key: "config.yaml", + } p.Spec.ReloadStrategy = ptr.To(tc.reloadStrategy) - firstConfig := ` -global: - scrape_interval: 1m -scrape_configs: - - job_name: testReloadConfig - metrics_path: /metrics - static_configs: - - targets: - - 111.111.111.111:9090 -` - - var bufOne bytes.Buffer - if err := operator.GzipConfig(&bufOne, []byte(firstConfig)); err != nil { - t.Fatal(err) - } - firstConfigCompressed := bufOne.Bytes() - - cfg := &v1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("prometheus-%s", name), - }, - Data: map[string][]byte{ - "prometheus.yaml.gz": firstConfigCompressed, - "configmaps.json": []byte("{}"), - }, - } - svc := framework.MakePrometheusService(p.Name, "not-relevant", v1.ServiceTypeClusterIP) - if _, err := framework.KubeClient.CoreV1().Secrets(ns).Create(context.Background(), cfg, metav1.CreateOptions{}); err != nil { + cfg := &v1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("additional-config-%s", name), + }, + Data: map[string][]byte{ + "config.yaml": []byte(` +- job_name: testReloadConfig + metrics_path: /metrics + static_configs: + - targets: + - 111.111.111.111:9090 +`), + }, + } + + cfg, err := framework.KubeClient.CoreV1().Secrets(ns).Create(context.Background(), cfg, metav1.CreateOptions{}) + if err != nil { t.Fatal(err) } @@ -1195,30 +1190,14 @@ scrape_configs: t.Fatal(err) } - secondConfig := ` -global: - scrape_interval: 1m -scrape_configs: - - job_name: testReloadConfig - metrics_path: /metrics - static_configs: - - targets: - - 111.111.111.111:9090 - - 111.111.111.112:9090 -` - - var bufTwo bytes.Buffer - if err := operator.GzipConfig(&bufTwo, []byte(secondConfig)); err != nil { - t.Fatal(err) - } - secondConfigCompressed := bufTwo.Bytes() - - cfg, err := framework.KubeClient.CoreV1().Secrets(ns).Get(context.Background(), cfg.Name, metav1.GetOptions{}) - if err != nil { - t.Fatal(fmt.Errorf("could not retrieve previous secret: %w", err)) - } - - cfg.Data["prometheus.yaml.gz"] = secondConfigCompressed + cfg.Data["config.yaml"] = []byte(` +- job_name: testReloadConfig + metrics_path: /metrics + static_configs: + - targets: + - 111.111.111.111:9090 + - 111.111.111.112:9090 +`) if _, err := framework.KubeClient.CoreV1().Secrets(ns).Update(context.Background(), cfg, metav1.UpdateOptions{}); err != nil { t.Fatal(err) }