Top favorite tools to make working with Kubernetes cluster easier

kubectx

Kubectx is helpful for multi-cluster installations, where you need to switch context between one cluster and another. You can make it easy to switch between the clusters in your kubeconfig.

Link: https://github.com/ahmetb/kubectxarrow-up-right

Installation

macOS

🎊 If you use Homebrewarrow-up-right you can install it like this:

brew install kubectx

Linux

sudo apt install kubectx

Usage

USAGE:
  kubectx                   : list the contexts
  kubectx <NAME>            : switch to context <NAME>
  kubectx -                 : switch to the previous context
  kubectx -c, --current     : show the current context name
  kubectx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
  kubectx <NEW_NAME>=.      : rename current-context to <NEW_NAME>
  kubectx -d <NAME>         : delete context <NAME> ('.' for current-context)
                              (this command won't delete the user/cluster entry
                              that is used by the context)
  kubectx -u, --unset       : unset the current context

kubens

kubens helps you switch between Kubernetes namespaces smoothly.

Link: https://github.com/ahmetb/kubectxarrow-up-right

Installation

macOS

🎊 If you use Homebrewarrow-up-right you can install it like this:

Linux

Usage

stern

stern allows you to tail multiple pods on Kubernetes and multiple containers within the pod. Each result is color-coded for quicker debugging.

Link: https://github.com/wercker/sternarrow-up-right

Installation

Homebrew

On macOS, you can also install Stern using Homebrewarrow-up-right:

Usage

Tail the gateway container running inside of the envvars pod on staging

Show auth activity from 15min ago with timestamps

zsh auto-completion

The kubectl completion script for Zsh can be generated with the command kubectl completion zsh.

Link: https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-zsh/arrow-up-right

Installation

To do so in all your shell sessions, add the following to your ~/.zshrc file:

If you have an alias for kubectl, you can extend shell completion to work with that alias:

After reloading your shell, kubectl autocompletion should be working.

Usage

You don't need to copy-pasting pod names but just type the first few letters and press the tab.

K9s

K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your applications in the wild.

Link: https://github.com/derailed/k9sarrow-up-right

Installation

K9s is available on Linux, macOS and Windows platforms.

Via Homebrew for macOS or LinuxBrew for Linux

Via Chocolateyarrow-up-right for Windows

Usage

kubectl-aliases

kubectl-aliases generates hundreds of convenient shell aliases for kubectl, so you no longer need to spell out every single command and --flag over and over again.

Link: https://github.com/ahmetb/kubectl-aliasesarrow-up-right

Installation

You can directly download the .kubectl_aliases filearrow-up-right and save it in your $HOME directory, then edit your .bashrc/.zshrc file with:

Usage

  • k=kubectl

    • sys=--namespace kube-system

  • commands:

    • g=get

    • d=describe

    • rm=delete

    • a:apply -f

    • ak:apply -k

    • k:kustomize

    • ex: exec -i -t

    • lo: logs -f

  • resources:

    • po=pod, dep=deployment, ing=ingress, svc=service, cm=configmap, sec=secret,ns=namespace, no=node

  • flags:

    • output format: oyaml, ojson, owide

    • all: --all or --all-namespaces depending on the command

    • sl: --show-labels

    • w=-w/--watch

  • value flags (should be at the end):

    • n=-n/--namespace

    • f=-f/--filename

    • l=-l/--selector

Conclusion

With these great tools, you'll be ready to build some amazing applications with Kubernetes cluster faster, simpler, and easier.

Last updated