# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: otel
spec:
  image: otel/opentelemetry-collector-contrib:0.112.0
  # We need to specify ports so remote sampler is exposed.
  ports:
    - port: 4317
      name: otlp
    - port: 4318
      name: otlp-grpc
    - port: 5778
      name: jaeger
    - port: 14250
      name: jaeger-grpc
  # Connect the config-map w/ our jaeger sampler config so we can update it quickly.
  volumes:
  - name: sampling-config-volume
    configMap:
      name: remote-sampling-config
  volumeMounts:
  - name: sampling-config-volume
    mountPath: /etc/otel/sampling
    readOnly: true
  # Ensure the jaeger remote sampler config is enabled as an extension.
  config: |
    receivers:
      otlp:
        protocols:
          grpc:
            endpoint: 0.0.0.0:4317
          http:
            endpoint: 0.0.0.0:4318
    exporters:
      debug:
    extensions:
      jaegerremotesampling:
        source:
          reload_interval: 60s
          file: /etc/otel/sampling/sampling.json
    service:
      extensions: [jaegerremotesampling]
      pipelines:
        traces:
          receivers: [otlp]
          processors: []
          exporters: [debug]
