diff --git a/hack/install-targetallocator-prometheus-crds.sh b/hack/install-targetallocator-prometheus-crds.sh index a905925eb0..1e0ad04d8f 100755 --- a/hack/install-targetallocator-prometheus-crds.sh +++ b/hack/install-targetallocator-prometheus-crds.sh @@ -5,4 +5,6 @@ if [[ "$(kubectl api-resources --api-group=monitoring.coreos.com -o name)" ]]; t else kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml + kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml + kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml fi diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml new file mode 100644 index 0000000000..5822cbf16d --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-assert.yaml @@ -0,0 +1,57 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: prometheus-cr-v1beta1-collector +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: prometheus-cr-v1beta1-targetallocator +status: + observedGeneration: 1 + readyReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +data: + targetallocator.yaml: + ( contains(@, join(':', ['service_monitor_selector', ' null'])) ): true + ( contains(@, join(':', ['pod_monitor_selector', ' null'])) ): true + ( contains(@, join(':', ['probe_selector', ' null'])) ): true + ( contains(@, join(':', ['scrape_config_selector', ' null'])) ): false + ( contains(@, join(':', ['matchlabels', ' {}}'])) ): false + ( contains(@, join(':', ['matchexpressions', ' {}}'])) ): false +kind: ConfigMap +metadata: + name: prometheus-cr-v1beta1-targetallocator + +--- +apiVersion: v1 +data: + collector.yaml: | + exporters: + prometheus: + endpoint: 0.0.0.0:9090 + receivers: + prometheus: + config: {} + target_allocator: + collector_id: ${POD_NAME} + endpoint: http://prometheus-cr-v1beta1-targetallocator:80 + interval: 30s + service: + pipelines: + metrics: + exporters: + - prometheus + receivers: + - prometheus + telemetry: + metrics: + address: 0.0.0.0:8888 +kind: ConfigMap +metadata: + name: prometheus-cr-v1beta1-collector-19c94a81 diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml new file mode 100644 index 0000000000..a17b2682e3 --- /dev/null +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/02-install.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: prometheus-cr-v1beta1 +spec: + config: + receivers: + prometheus: + config: + scrape_configs: [] + + processors: + + exporters: + prometheus: + endpoint: 0.0.0.0:9090 + service: + pipelines: + metrics: + receivers: [prometheus] + exporters: [prometheus] + mode: statefulset + serviceAccount: collector + targetAllocator: + enabled: true + prometheusCR: + enabled: true + scrapeInterval: 1s + scrapeConfigSelector: {} + serviceAccount: ta +--- +apiVersion: monitoring.coreos.com/v1alpha1 +kind: ScrapeConfig +metadata: + name: scrape-config-cr +spec: + kubernetesSDConfigs: + - role: Node diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index c361477488..28f94d2e33 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -22,3 +22,9 @@ spec: file: 01-install.yaml - assert: file: 01-assert.yaml + - name: step-02 + try: + - apply: + file: 02-install.yaml + - assert: + file: 02-assert.yaml