Course contentsShow
← Cloud and Infrastructure
Lesson 2086 of 2,98944. Observability - TracingFree lesson

OpenTelemetry in Kubernetes Environments

Deploying the OTel collector as DaemonSet or sidecar, and instrumenting containerized applications with OTel.

OpenTelemetry in Kubernetes Environments

What You'll Learn

You'll learn how to deploy the OpenTelemetry Collector in Kubernetes clusters and instrument containerized applications to generate distributed traces.

Core Concept

Running OpenTelemetry in Kubernetes requires strategic deployment decisions. The OTel Collector can be deployed in two primary patterns:

DaemonSet Pattern

Deploy the collector as a DaemonSet to run one collector pod on each node. Applications send telemetry to the local collector via the node's network. This approach reduces network hops and centralizes resource management at the node level—think of it as having a local post office on every street rather than making everyone travel to a central facility.

Sidecar Pattern

Deploy a collector container alongside each application pod in the same pod specification. The application sends traces to localhost, ensuring telemetry collection even if the pod moves between nodes. This provides isolation but increases resource overhead—like giving each apartment its own mailbox instead of a shared building entrance.

Instrumenting Containerized Applications

Your containerized apps need OTel SDKs installed (as covered in prior lessons). Key considerations:

  • Environment variables: Configure OTel exporters via OTEL_EXPORTER_OTLC_ENDPOINT to point to your collector service
  • Service discovery: Use Kubernetes DNS names like otel-collector.observability.svc.cluster.local
  • Context propagation: Ensure trace context flows across pod boundaries through HTTP headers
  • Resource attributes: Tag traces with k8s.pod.name, k8s.namespace.name for proper identification

The collector then forwards processed traces to your backend (Jaeger, Zipkin, or commercial solutions) using exporters configured in its pipeline.

Key Takeaway: Deploy OTel collectors as DaemonSets for efficiency or sidecars for isolation, and configure containerized apps to export traces using Kubernetes-aware service discovery and resource attributes.