Skip to content
17 changes: 17 additions & 0 deletions .chloggen/fix-ta-tlsconfig-scrapeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# 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: Allow collector to use TLS Config from Target Allocator with ScrapeConfig

# One or more tracking issues related to the change
issues: [3724]

# (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: |
This change allows the target allocator to configure TLS Config for a collector using the ScrapeConfig.
2 changes: 1 addition & 1 deletion cmd/otel-allocator/internal/watcher/promOperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewPrometheusCRWatcher(ctx context.Context, logger logr.Logger, cfg allocat
},
}

generator, err := prometheus.NewConfigGenerator(promLogger, prom, prometheus.WithEndpointSliceSupport())
generator, err := prometheus.NewConfigGenerator(promLogger, prom, prometheus.WithEndpointSliceSupport(), prometheus.WithInlineTLSConfig())

if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/otel-allocator/internal/watcher/promOperator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ func getTestPrometheusCRWatcher(

promOperatorLogger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelWarn}))

generator, err := prometheus.NewConfigGenerator(promOperatorLogger, prom, prometheus.WithEndpointSliceSupport())
generator, err := prometheus.NewConfigGenerator(promOperatorLogger, prom, prometheus.WithEndpointSliceSupport(), prometheus.WithInlineTLSConfig())
if err != nil {
t.Fatal(t, err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-cr-v1beta1-targetallocator
status:
observedGeneration: 1
readyReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: prometheus-cr-v1beta1-collector
status:
readyReplicas: 1
replicas: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: ta
---
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: collector
---
apiVersion: v1
kind: Secret
metadata:
name: collector
annotations:
kubernetes.io/service-account.name: collector
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: (join('-', ['ta', $namespace]))
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: (join('-', ['collector', $namespace]))
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- nodes/proxy
- 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: ClusterRole
metadata:
name: (join('-', ['opentelemetry-operator-controller-manager-cert-manager-role', $namespace]))
rules:
- apiGroups:
- cert-manager.io
resources:
- issuers
- certificaterequests
- certificates
verbs:
- create
- get
- list
- watch
- update
- patch
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: (join('-', ['opentelemetry-operator-controller-manager-cert-manager-role', $namespace]))
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: (join('-', ['opentelemetry-operator-controller-manager-cert-manager-role', $namespace]))
subjects:
- kind: ServiceAccount
name: opentelemetry-operator-controller-manager
namespace: opentelemetry-operator-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: (join('-', ['ta', $namespace]))
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: (join('-', ['ta', $namespace]))
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: (join('-', ['collector', $namespace]))
subjects:
- kind: ServiceAccount
name: collector
namespace: ($namespace)
---
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]
telemetry:
logs:
level: "DEBUG"
development: true
encoding: "json"
mode: statefulset
serviceAccount: collector
targetAllocator:
enabled: true
prometheusCR:
enabled: true
scrapeInterval: 1s
scrapeConfigSelector: {}
serviceAccount: ta
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: batch/v1
kind: Job
metadata:
name: check-ta-scrape-config-v1beta1
status:
succeeded: 1
---
apiVersion: batch/v1
kind: Job
metadata:
name: check-ta-jobs-scrape-configs-v1beta1
status:
succeeded: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: Job
metadata:
name: check-ta-scrape-config-v1beta1
spec:
template:
metadata:
labels:
checker: "true"
spec:
restartPolicy: OnFailure
containers:
- name: check-metrics
image: curlimages/curl
args:
- /bin/sh
- -c
- curl -s http://prometheus-cr-v1beta1-targetallocator/scrape_configs | grep "scrape-config-cr"
---
apiVersion: batch/v1
kind: Job
metadata:
name: check-ta-jobs-scrape-configs-v1beta1
spec:
template:
metadata:
labels:
checker: "true"
spec:
restartPolicy: OnFailure
containers:
- name: check-metrics
image: curlimages/curl
args:
- /bin/sh
- -c
- curl -s http://prometheus-cr-v1beta1-targetallocator/jobs | grep "scrape-config-cr"
Loading
Loading