Kubectl REPL
The official kubectl tool is great. Kubectl REPL improves on it by persisting current namespace and adding variables.
Get Mikuláš’s stories in your inbox
Join Medium for free to get updates from this writer.
Kubectl REPL starts by asking for a namespace to begin in. This very well suits the use-case where every application has its own namespace. You answer with the closest abbreviation: for example, kube orksys forkube-system. Small typos such as kybe-system will work as well.
With namespace selected the REPL presents a prompt. Your input is prefixed with kubectl -n $NAMESPACE and evaluated in a shell. This means pipes, redirection and other constructs work as expected. The goal is to enhance kubectl without you even noticing. Kubectl REPL should be very intuitive.
Finally, Kubectl REPL introduces variables. You might have noticed the output lines are numbered. Those are variables and can be used in subsequent commands.
In the above example, get pods sets variables from $1 up to $5. Instead of copy pasting the pod name, you can invoke logs $3, which evaluates to logs logspout-mzbc8. Variables can be used anywhere, not just the logs subcommand, such as delete pod $3 && echo $3 > /tmp/pod.txt. More realistically, this is how you can use a variable to quickly exec into a pod:
Head over to GitHub repo for complete readme, releases to install and docker image: https://github.com/Mikulas/kubectl-repl/








