Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TargetAllocator): allow configuration of PrometheusCR namespaceSelectors #3573

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus-cr-collector
status:
readyReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-cr-targetallocator
status:
observedGeneration: 1
readyReplicas: 1
replicas: 1
---
apiVersion: v1
data:
targetallocator.yaml:
( contains(@, join(':', ['service_monitor_namespace_selector', ' {}'])) ): true
( contains(@, join(':', ['pod_monitor_namespace_selector', ' {}'])) ): true
( contains(@, join(':', ['probe_namespace_selector', ' {}'])) ): true
( contains(@, join(':', ['scrape_config_namespace_selector', '{}'])) ): true
kind: ConfigMap
metadata:
name: prometheus-cr-v1beta1-targetallocator
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: ta
---
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: collector
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: targetallocator-prometheuscr
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- services
- endpoints
- configmaps
- secrets
- namespaces
verbs:
- get
- watch
- list
- apiGroups:
- apps
resources:
- statefulsets
- services
- endpoints
verbs:
- get
- watch
- list
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- get
- watch
- list
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- watch
- list
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
- podmonitors
- scrapeconfigs
- probes
verbs:
- get
- watch
- list
- nonResourceURLs:
- /metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: collector-prometheuscr
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- nodes/metrics
- services
- endpoints
- namespaces
verbs:
- get
- watch
- list
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- watch
- list
- nonResourceURLs:
- /metrics
- /metrics/cadvisor
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: (join('-', ['ta', $namespace]))
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: targetallocator-prometheuscr
subjects:
- kind: ServiceAccount
name: ta
namespace: ($namespace)
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: (join('-', ['collector', $namespace]))
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: collector-prometheuscr
subjects:
- kind: ServiceAccount
name: collector
namespace: ($namespace)
---
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: prometheus-cr
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
podMonitorNamespaceSelector: {}
serviceMonitorNamespaceSelector: {}
scrapeConfigNamespaceSelector: {}
probeNamespaceSelector: {}
swiatekm marked this conversation as resolved.
Show resolved Hide resolved
serviceAccount: ta