Open paebersold-tyro opened 2 months ago
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: otelcol
spec:
mode: statefulset
serviceAccount: otelcol-metrics-collector
volumes:
- emptyDir:
medium: Memory
name: istio-certs
volumeMounts:
- mountPath: /etc/prom-certs/
name: istio-certs
podAnnotations:
traffic.sidecar.istio.io/includeInboundPorts: "" # do not intercept any inbound ports
traffic.sidecar.istio.io/includeOutboundIPRanges: "" # do not intercept any outbound traffic
proxy.istio.io/config: | # configure an env variable `OUTPUT_CERTS` to write certificates to the given folder
proxyMetadata:
OUTPUT_CERTS: /etc/istio-output-certs
sidecar.istio.io/userVolumeMount: '[{"name": "istio-certs", "mountPath": "/etc/istio-output-certs"}]' # mount the shared volume at sidecar proxy
targetAllocator:
enabled: false
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: opentelemetry-targetallocator
app.kubernetes.io/instance: otel-metrics-scraping.otelcol
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: otelcol-targetallocator
app.kubernetes.io/part-of: opentelemetry
name: otelcol-targetallocator
namespace: otel-metrics-scraping
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: opentelemetry-targetallocator
app.kubernetes.io/instance: otel-metrics-scraping.otelcol
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: otelcol-targetallocator
app.kubernetes.io/part-of: opentelemetry
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
proxy.istio.io/config: |
proxyMetadata:
OUTPUT_CERTS: /etc/istio-output-certs
sidecar.istio.io/userVolumeMount: '[{"name": "istio-certs", "mountPath": "/etc/istio-output-certs"}]'
traffic.sidecar.istio.io/includeInboundPorts: ""
traffic.sidecar.istio.io/includeOutboundIPRanges: ""
labels:
sidecar.istio.io/inject: "true"
app.kubernetes.io/component: opentelemetry-targetallocator
app.kubernetes.io/instance: otel-metrics-scraping.otelcol
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: otelcol-targetallocator
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
spec:
containers:
- env:
- name: OTELCOL_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
image: ghcr.io/open-telemetry/opentelemetry-operator/target-allocator:0.103.0
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3
httpGet:
path: /livez
port: 8080
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: ta-container
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /readyz
port: 8080
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /conf
name: ta-internal
- mountPath: /etc/prom-certs/
name: istio-certs
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccountName: otelcol-metrics-target-allocator
shareProcessNamespace: false
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
items:
- key: targetallocator.yaml
path: targetallocator.yaml
name: otelcol-targetallocator
name: ta-internal
- emptyDir:
medium: Memory
name: istio-certs
apiVersion: v1
data:
targetallocator.yaml: |
allocation_strategy: consistent-hashing
collector_selector:
matchlabels:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: otel-metrics-scraping.otelcol
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
matchexpressions: []
config:
scrape_configs:
- job_name: otel-collector
scrape_interval: 30s
static_configs:
- targets:
- 0.0.0.0:8888
filter_strategy: relabel-config
prometheus_cr:
enabled: true
pod_monitor_selector:
matchlabels: {}
matchexpressions: []
scrape_interval: 30s
service_monitor_selector:
matchlabels: {}
matchexpressions: []
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/component: opentelemetry-targetallocator
app.kubernetes.io/instance: otel-metrics-scraping.otelcol
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/name: otelcol-targetallocator
app.kubernetes.io/part-of: opentelemetry
app.kubernetes.io/version: latest
name: otelcol-targetallocator
namespace: otel-metrics-scraping
The way to get around this bug currently is to disable the target allocator in the OpenTelemetryCollector CRD and then deploy the target allocator with the deployment and config map that you see posted above. I have tested and it works just fine. Hope it help you out.
Component(s)
target allocator
What happened?
Description
Hello, this is half bug/half feature request.
We are using the otel-operator as a daemonset with the target allocator enabled (via the operator helm chart). We are also using istio (sidecar being auto injected). For the setting up of prometheus scraping endpoints inside the istio mesh we are following the istio guidelines (https://istio.io/latest/docs/ops/integrations/prometheus/#option-2-customized-scraping-configurations) around this. In short we need to add a podannotaton and a volume and volumemount setup on the pod (ie the collector) doing the scraping.
I can do this via the OpenTelemetryCollector setup with 'podannotations/volumes/volumenmounts'. However only the podannotations are passed onto the target allocator deployment. Not the volumes/volumemounts. So the target allocator fails to start as it tries to (via the annotation) mount a volume that doesn't exist.
Is there a way around this within the OpenTelemetryCollector config?
Steps to Reproduce
Setup OpenTelemetryCollector object with istio suggested setup
Expected Result
Target allocator gets the same resources as the collector pods
Actual Result
It doesn't so is unable to start. See log below.
Kubernetes Version
1.30
Operator version
0.102.0
Collector version
0.103.0
Environment information
Helm chart - https://open-telemetry.github.io/opentelemetry-helm-charts / opentelemetry-operator / 0.62.0 Target allocator - 0.107.0
Log output
Additional context
OpenTelemetryCollector config
Generated target allocator deployment