Sending Telemetry Data to the OpenTelemetry Collector with Sidecar Injection

You can configure the Alauda build of OpenTelemetry v2 to inject the OpenTelemetry Collector as a sidecar container into your application pods. The sidecar Collector runs in the same pod as your application, enabling applications to send telemetry data to the Collector via localhost without complex network configuration.

Prerequisites

  • Alauda build of OpenTelemetry v2 Operator is installed.
  • Alauda Build of Jaeger v2 is installed and deployed.
  • An active ACP CLI (kubectl) session by a cluster administrator with the cluster-admin role.

Procedure

  1. Deploy the OpenTelemetry Collector as a sidecar by running the following command:

    kubectl apply -f - <<EOF
    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel-sidecar
      namespace: observability
    spec:
      mode: sidecar
      image: "<image-registry>/asm/opentelemetry-collector:<image-tag>"
      config:
        receivers:
          otlp:
            protocols:
              grpc:
                endpoint:
              http:
                endpoint:
        processors:
          batch: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 80
            spike_limit_percentage: 20
        exporters:
          otlp:
            endpoint: "jaeger-<example>-collector:4317"
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [otlp]
              processors: [memory_limiter, batch]
              exporters: [otlp]
    EOF
    1. Replace <image-registry>/asm/opentelemetry-collector:<image-tag> with the actual image registry and tag for the sidecar Collector.
    2. Replace jaeger-<example>-collector with the actual service name of your Alauda Build of Jaeger v2 collector. The format is typically <instance-name>-collector.
  2. Create a deployment that uses the sidecar injection by adding the annotation sidecar.opentelemetry.io/inject: "true" and using the created ServiceAccount:

    kubectl apply -f - <<EOF
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-app
      namespace: observability
    spec:
      selector:
        matchLabels:
          app: my-app
      replicas: 1
      template:
        metadata:
          labels:
            app: my-app
          annotations:
            sidecar.opentelemetry.io/inject: "true"
        spec:
          containers:
          - name: app
            image: myapp:latest
            ports:
            - containerPort: 8080
    EOF