Introducing kubectl-repl

Wrap kubectl with namespace and variables. Run commands in current namespace without copy and pasting all the time!

kubectl-repl demo

Almost any kubectl interaction consists of those steps:

  1. Inspect the current state of a certain object in a given namespace and cluster.
  2. In the very same namespace and cluster, invoke a command on one or many of the listed objects.
  3. Verify result of the just issued command.

With a rescale operation traditional kubectl flow may look like this:

  1. kubectl -n wacky-monkey get pods
  2. kubectl -n wacky-monkey get deploy
  3. kubectl -n wacky-monkey scale deploy/monkey-deployment --replicas=3
  4. kubectl -n wacky-monkey get pods

The repetitive nature of those commands makes it hard to focus on the workflow itself, even with a shell history. With kubectl-repl, the flow can be altered to:

  1. kubectl-repl and select the namespace wacky-monkey
  2. get pods
  3. get deploy
  4. scale deploy/$1 --replicas=3
  5. get pods

The extra step of launching the REPL simplifies all further commands. Note that we did’t even have to rewrite (or copypaste) the name of the deployment and we substituted it with $1.

See https://github.com/clusterise/kubectl-repl and give the tool a try.


Alternatives:

A more complete list is available at https://github.com/ramitsurana/awesome-kubernetes#apicli-adaptors