Enhancing Kubernetes Experience with Kubecolor

Enhancing Kubernetes Experience with Kubecolor

Introduction

Working with Kubernetes command-line tools can sometimes be challenging, especially when sifting through extensive output data. This is where ‘kubecolor’ comes into the picture, a tool designed to add a splash of colour to the Kubernetes command-line experience, enhancing readability and user efficiency.

What is it?

It is an open-source command-line tool that colourises the output of Kubernetes commands. This tool is designed to work as a drop-in replacement for ‘kubectl’, the Kubernetes command-line interface. It differentiates between various elements in the command output, such as resource names, types, statuses, and numbers, applying different colours to each for easier identification and analysis.

Benefits of Using Kubecolor

  1. Improved Readability: By color-coding different parts of the output, it makes it easier to scan through and understand complex Kubernetes data.
  2. Error Highlighting: It highlights errors in red, ensuring that they are immediately noticeable.
  3. Customisation: Users can customise the colour schemes to suit their preferences or to adhere to accessibility standards.
  4. Seamless Integration: Kubecolor is designed to work seamlessly with existing Kubernetes setups, requiring no additional configuration.

How to Install Kubecolor

Kubecolor can be installed on any system where ‘kubectl’ is used. Installation methods vary based on the operating system. For instance, on a Unix-like system, you can install kubecolor using Homebrew:

brew install dty1er/tap/kubecolor

Alternatively, you can download the pre-compiled binaries from the GitHub releases page here: – https://github.com/hidetatz/kubecolor

Windows Installation:

To run install it on Windows, you have two main approaches:

  1. Windows Subsystem for Linux (WSL): If you’re using WSL, install kubecolor as you would in a standard Linux environment. This method provides an experience closest to that on Unix-like systems. Personally, I run both on my development machine.
  2. Direct Windows Installation: You can also install kubecolor directly on Windows by downloading the Windows-specific binary from the kubecolor GitHub releases page. After downloading, include the binary in your system’s PATH to access it from any command line interface like PowerShell or Command Prompt.

Using it on the command line

After installation, using kubecolor is straightforward. Simply replace ‘kubectl’ with ‘kubecolor’ in your Kubernetes commands. For example:

kubecolor get pods

It output something like this: –

image-15 Enhancing Kubernetes Experience with Kubecolor

This command will display the output of ‘kubectl get pods’ with colourised elements, making it easier to interpret the output.

kubecolor understands every subcommands and options which are available for kubectl. What you have to do is just using kubecolor instead of kubectl like:kubecolor –context=your_context get pods -o json

If you want to make the colourised kubectl default on your shell, just add this line into your shell configuration file: alias kubectl=”kubecolor”

Customising

Kubecolor offers the flexibility of customising the colour scheme. You can set your preferred colours through environment variables, making the tool adaptable to various preferences and accessibility needs. The customisation process is detailed in the tool’s GitHub repository documentation.

Conclusion

Kubecolor is a valuable tool for developers and system administrators working with Kubernetes. It enhances the command-line experience by making output data more readable and easier to interpret. Its ease of installation, seamless integration, and customisation options make it a must-have tool in the Kubernetes toolkit.

This reminds me of the K9’s which I have written about here: – Manage K8s with K9s.

Stephen

Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.