Skip to content
Alex Golshani edited this page Nov 15, 2020 · 12 revisions

Trubka is a CLI tool which gives you everything you need to

  • Manage, query and troubleshoot your Kafka cluster.
  • Consume protocol buffer and plain text messages from Kafka.
  • Publish protocol buffer and plain text messages to Kafka.

If you need to play around with Trubka locally, you can download the docker compose file from the repo and spin up a single node Kafka cluster on your machine:

$> mkdir -p ~/local_kafka
$> cd ~/local_kafka
$> wget https://raw.githubusercontent.com/xitonix/trubka/master/docker-compose.yml
$> docker-compose up

Installation

macOS

$> brew tap xitonix/trubka
$> brew install trubka

NOTE

If you used brew to install any version older than v3.2.1, you may need to re-install trubka to upgrade to v3.2.1+.

Pre built binaries

Download the pre-built binaries for the platform of your choice from the releases page. Installation packages are also available for Windows, DEB and RPM.

Build from source

Clone the repo locally and build trubka from source. You can also use Make to compile the code.

Authentication

If your Kafka cluster has SASL or TLS enabled, Trubka's got your back. You can inject SASL credentials or TLS certs into all the commands that communicate with your Kafka cluster using the provided flags.

--sasl-mechanism=none      SASL authentication mechanism.
-U, --sasl-username=SASL-USERNAME
                           SASL authentication username.
-P, --sasl-password=SASL-PASSWORD
                           SASL authentication password.
--sasl-version=v1          SASL handshake version.


--tls                      Enables TLS (Unverified by default).
--ca-cert=CA-CERT          Trusted root certificates for verifying the server.
--client-cert=CLIENT-CERT  Client certification file to enable mutual TLS authentication.
--client-key=CLIENT-KEY    Client private key file to enable mutual TLS authentication.

Environment Variables

It is possible to ask Trubka to read the cli flags from the system's environment variables. The flags must be in TRUBKA_FLAG_NAME format. For example the value of --proto-root parameter can be read from TRUBKA_PROTO_ROOT if it's provided.

NOTE

Providing the same cli flag when running Trubka will override its environment variable counterpart. That means --proto-root=/tmp/protos will override TRUBKA_PROTO_ROOT=/dev/contracts and trubka will run with /tmp/protos as proto root.

Enable Auto Completion

In order to enable auto completion in bash or zsh, you can add the following line to your shell's startup script:

ZSH

eval "$(trubka --completion-script-zsh)"

BASH

eval "$(trubka --completion-script-bash)"

Themes and Colours

Whenever applicable, Trubka highlights the json output (only when it writes into stdout). The highlighting theme can be picked from a pre-defined list of styles using the --style flag or can be set to none to disable. Here is the list of supported styles:

  • autumn
  • dracula
  • emacs
  • friendly
  • fruity
  • github
  • lovelace
  • monokai
  • monokailight
  • native
  • paraiso-dark
  • paraiso-light
  • pygments
  • rrt
  • solarized-dark
  • solarized-light
  • swapoff
  • tango
  • trac
  • vim

I used the amazing Chroma package for highlighting. You can check their playground to see how each theme will look like in your terminal.

Apart from the json output, you may see some colours and highlights in other commands' output as well. For example, the highlighted search result of the consume commands. You can disable all the colours and highlights (including the json styling) altogether by setting --no-colour flag.