Skip to content

Instantly share code, notes, and snippets.

@joaopgrassi
Last active September 8, 2021 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaopgrassi/2aaa48b1e025403b358c4876959ba5d7 to your computer and use it in GitHub Desktop.
Save joaopgrassi/2aaa48b1e025403b358c4876959ba5d7 to your computer and use it in GitHub Desktop.
OpenTelemetry collector configured to export to Jaeger

Deploying a OpenTelemetry collector in a k8s cluster

  1. Make sure to first have a working Jaeger in the cluster: https://gist.github.com/joaopgrassi/8eb001d94310effef038364e4f6994ab

  2. Run the following command to deploy the collector in your k8s cluster:

Note: The yml below expects the Jaeger services to be deployed within the observability using the names from the gist above. If you follow that it should all work. If not, make sure the dns names are the correct.

kubectl apply -n observability -f <<EOF
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: otel-collector-conf
  namespace: observability
  labels:
    app: opentelemetry
    component: otel-collector-conf
data:
  otel-collector-config: |
    receivers:
      otlp:
        protocols:
          grpc:
          http:
    processors:
    exporters:
      logging:
      jaeger:
        endpoint: "simplest-collector-headless.observability:14250"
        insecure: "true"
    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: []
          exporters: [logging, jaeger]
---
apiVersion: v1
kind: Service
metadata:
  name: otel-collector
  namespace: observability
  labels:
    app: opentelemetry
    component: otel-collector
spec:
  ports:
  - name: otlpgrpc # Default endpoint for OpenTelemetry gRPC receiver.
    port: 4317
    protocol: TCP
    targetPort: 4317
  - name: otlphttp # Default endpoint for OpenTelemetry HTTP receiver.
    port: 4318
    protocol: TCP
    targetPort: 4318
  selector:
    component: otel-collector
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: otel-collector
  namespace: observability
  labels:
    app: opentelemetry
    component: otel-collector
spec:
  replicas: 1
  selector:
    matchLabels:
      app: opentelemetry
      component: otel-collector
  template:
    metadata:
      labels:
        app: opentelemetry
        component: otel-collector
    spec:
      containers:
      - name: otel-collector
        args:
        - --config=/conf/otel-collector-config.yaml
        image: otel/opentelemetry-collector:0.33.0
        ports:
          - containerPort: 4317 
          - containerPort: 4318
        volumeMounts:
        - name: otel-collector-config-vol
          mountPath: /conf
#        - name: otel-collector-secrets
#          mountPath: /secrets
      volumes:
      - configMap:
          name: otel-collector-conf
          items:
            - key: otel-collector-config
              path: otel-collector-config.yaml
        name: otel-collector-config-vol
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment