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 ⭐

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

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

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay