# services/logging/otel-collector-helmrelease.yaml
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: otel-collector
  namespace: logging
spec:
  interval: 15m
  timeout: 10m
  chart:
    spec:
      chart: opentelemetry-collector
      version: "~0.143.0"
      sourceRef:
        kind: HelmRepository
        name: opentelemetry
        namespace: flux-system
  values:
    fullnameOverride: otel-collector
    image:
      repository: otel/opentelemetry-collector
      tag: "0.143.0"
    mode: deployment
    replicaCount: 1
    ports:
      otlp:
        enabled: true
        containerPort: 4317
        servicePort: 4317
        protocol: TCP
      otlp-http:
        enabled: true
        containerPort: 4318
        servicePort: 4318
        protocol: TCP
      jaeger-compact:
        enabled: false
      jaeger-thrift:
        enabled: false
      jaeger-grpc:
        enabled: false
      zipkin:
        enabled: false
      metrics:
        enabled: false
    config:
      receivers:
        otlp:
          protocols:
            grpc:
              endpoint: ${env:MY_POD_IP}:4317
            http:
              endpoint: ${env:MY_POD_IP}:4318
      processors:
        memory_limiter:
          check_interval: 5s
          limit_percentage: 80
          spike_limit_percentage: 25
        batch: {}
      exporters:
        otlp/data-prepper:
          endpoint: data-prepper.logging.svc.cluster.local:21890
          tls:
            insecure: true
      service:
        extensions:
          - health_check
        pipelines:
          traces:
            receivers: [otlp]
            processors: [memory_limiter, batch]
            exporters: [otlp/data-prepper]
    resources:
      requests:
        cpu: "100m"
        memory: "256Mi"
      limits:
        memory: "512Mi"
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
            - matchExpressions:
                - key: jetson
                  operator: In
                  values:
                    - "true"
            - matchExpressions:
                - key: hardware
                  operator: In
                  values:
                    - rpi5
        preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            preference:
              matchExpressions:
                - key: jetson
                  operator: In
                  values:
                    - "true"
