Skip to content

Commit

Permalink
e2e test prometheus operator crds
Browse files Browse the repository at this point in the history
Signed-off-by: qiyang <[email protected]>
  • Loading branch information
dominicqi committed Nov 19, 2024
1 parent d87da69 commit d3861c1
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hack/install-targetallocator-prometheus-crds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d3861c1

Please sign in to comment.