DEV Community

Cover image for Trace kubectl using OpenTelemetry
Adam Gardner
Adam Gardner

Posted on

Trace kubectl using OpenTelemetry

kubectl opentelemetry tracing

kubectl otel is a Kubernetes CLI plugin which will generate OpenTelemetry traces for any kubectl ... command you run and output them to a tracing storage backend of your choice.

For example, this command will time how long it takes to apply the deploy.yaml file and send the trace to a backend.

kubectl otel apply -f deploy.yaml
Enter fullscreen mode Exit fullscreen mode

You could also alias it so the tracing is seamless:

alias ko='kubectl otel'
ko apply -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

Prerequisites

  • Currently only supports Linux and MacOS
  • You must have a standalone binary of tracepusher in your path (ie. you are able to run tracepusher from the command line and see output)
  • You must have an OpenTelemetry collector somewhere so the spans can be sent there

Installation

krew listing - coming soon (hopefully)

For now:

  • Download kubectl-otel
  • Make it executable: chmod +x kubectl-otel
  • Move it to anywhere in your path (eg. /usr/local/bin): sudo mv kubectl-otel /usr/local/bin

Try it out: kubectl otel version should execute kubectl version and trace the time (expected to be quick eg. 0 seconds).

Code on GitHub

This plugin is fully open sourced on GitHub. Drop by, submit an enhancement PR and give the repo a ⭐

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay