Kubetools - a containerized Swiss Army Knife of k8s utilities

mshade | June 8, 2023, 2:31 p.m.

I often hop from computer to computer, and it always annoys me when my tools are out of sync from spot to spot. I've dabbled in the past with dotfiles repositories and other methods to keep tools, aliases, and shell configuration in sync, but inevitably, cross-platform difficulties creep in and the task of managing tools gets more involved than the time is worth.

To help alleviate some of that toil, I put together a containerized environment for some of my most commonly used tools for Kubernetes -- kubetools. It contains everything I need to work with my clusters and provides a common environment across workstations so I'm never reaching to install yet another binary.

Included in the image are:

  • kubectl (of course)
  • k9s - a TUI k8s interface
  • kubeconform - for validating k8s manifests
  • krew - the plugin system for kubectl with:
  • pv-migrate for easily moving data between PVCs
  • node-shell to quickly launch a shell on any kubernetes node
  • helm versions 2 and 3
  • helmfile
  • velero cli for managing velero backups
  • argocd cli for managing ArgoCD
  • vim and base configuration for quick editing
  • bash completion for all the tools that support it
  • helpful bash aliases for managing context and kubeconfig

The intent is to mount your ~/.kube directory and working directory into the container when launching, so you have your kubeconfig and code available for the task at hand.

Give it a shot! Here's an example of how to use it:

$ docker run -it --rm -v $PWD:/app -v ~/.kube:/home/.kube mshade/kubetools:latest

I tend to name my KUBECONFIG files by cluster name instead of combining contexts into one file - the image will prompt you for the kubeconfig files it sees available in your ~/.kube directory. Select the active one with a shell alias:

Available KUBECONFIGs:

setkube <configname> to switch context

kubetools:[/app]$ setkube rancher-desktop