
Kubectl is the main console interface for interacting with Kubernetes and, of course, an important tool in the hands of any administrator / DevOps engineer involved in the operation of such clusters. If you use it every day and do it really actively, then, as is typical of IT professionals, you probably thought about ways to simplify / automate your manipulations. Fortunately, this is the world of system administrators, Open Source and the console, so that, of course, there were already those who not only thought about it, but also embodied their needs in life - in the form of utilities that are now available to all "colleagues in the workshop ". About them and will be discussed in this short review.
kube-shell
- Github
- Language: Python *
- License: Apache 2.0
An interactive shell for kubectl, based on the
prompt-toolkit library for Python, which serves as a "replacement for the GNU readline and much more." This library implements automatic addition of input commands with drop-down explanations, syntax highlighting, and a number of other features that, in essence, make all the “interactivity” in the kube-shell. The case when it's easier to see once:

')
Among other features of this shell:
- automatic prompts that appear as you enter commands in the style of fish shell ;
- history of entered commands with search for partial matches;
- extended autocomplete features: fuzzy-search, substitution of values ​​from data received from the server;
- convenient switching between clusters and namespaces (there is a ticket to add a similar switch between users) ;
- edit mode vi.
In the obscure future
, the emergence of support for an SQL-like language
is also
expected to be performed for the execution of commands of the following form via kubectl:
ls <resource-name> select (property1, property2, property3) where (propery1=value1 and property2=value2) order by property3
The inspiration for the kube-shell was similar to the AWS API
shell :
aws-shell and
saws .
* The project also uses an auxiliary program on Go (it is funny called python_eats_cobra.go ) to generate a JSON file with commands, arguments, etc. available in kubectl. In the future, the main Python application works with this file.kube-prompt
- Github
- Language: Go
- License: MIT License
Another interactive shell is very similar in its essence to the previously described kube-shell and appeared a month later (according to the first commit in GitHub, which happened in July against June 2017). Its main difference is the use of the native for the Kubernetes community of the Go programming language instead of Python. However, Go did not have its own prompt-toolkit, so ... the author (Masashi Shibata from Japan) took and wrote
go-prompt , and on its basis implemented a new shell. And the results were very similar:
(The character set on the bottom right is a sequence of keystrokes on the keyboard to achieve such a result. More clearly - in this GIF-animation of 16 MB.)If you compare the kube-prompt with its Python-colleague through the eyes of the end user, then he has fewer additional chips (for example, there is no constant output of the current cluster / namespace and fast switching between them). But in it there is no need to enter "kubectl" at the beginning of all commands and this keeps the ability to add other shell commands via pipe ("|") - for example, grep when getting the list of pods.
Nevertheless, despite the fact that the kube-prompt is being developed by a single person and a little less in time, it is already slightly ahead in the number of stars on GitHub, so the prospects for further development of these competitive solutions are not so obvious.
kubectl-repl
- Github
- Language: Go
- License: Apache 2.0
The “REPL” in the name of this application is the same
Read – Eval – Print Loop cycle that implements a simple interactive environment inside the shell. In essence, kubectl-repl is an original “wrapper” that, after its launch, offers to enter further commands without mentioning kubectl and simplifies interaction with this utility due to two possibilities:
- Switching namespaces (one command selects the current one, which is then shown as relevant in the invitation and added to all subsequent kubectl calls);
- “Numbered” selection of items from lists returned by
kubectl get
.
The second feature is implemented in such a way that all the elements of the lists - for example, for the list of pods returned by the command
kubectl get pods | grep foobar
kubectl get pods | grep foobar
, - a column is added with variables of the form
$1
,
$2
,
$3
... These variables are available for use in further kubectl or shell commands. Example from documentation:
The kubectl-repl utility is quite young, developed by one enthusiast for less than a month.
k8sh
- Github
- Language: Bash
- License: Apache 2.0
Another attempt to make a simple wrapper around kubectl - this time on a regular Bash. After launch, it displays the current context (
kubectl config current-context
) and namespace in its invitation, offering short commands for changing them (
ct
and
ns
respectively), as well as a set of other aliases. For example:
kubectl describe
→ k describe
kubectl get pods
→ pods
kubectl get persistentvolumeclaims
→ pvc

The aliases loaded with the launch of k8sh can be extended by creating a
~/.k8sh_extensions
with your Bash code (there is
an example in the repository how to use this).
kubectl-aliases
- Github
- Language: Python, Bash
- License: Apache 2.0
A more “hardcore” version of Bash / zsh-alias for kubectl. Its author wrote a Python script that automatically generates a
.kubectl_aliases
file containing hundreds (!) Lines of the following form:
alias k='kubectl' … alias ka='kubectl apply -f' … alias ksyslo='kubectl --namespace=kube-system logs -f' … alias ksysgdep='kubectl --namespace=kube-system get deployment' … alias kgno='kubectl get nodes' … alias ksysgdepojson='kubectl --namespace=kube-system get deployment -o=json' …
As the author himself, who
announced his brainchild less than 2 weeks ago, notes, “this may look really stupid, but VERY USEFUL for me; [thanks to these aliases] I really save significant time in my daily workflow. ”
Other
- We have already written about kubectx for convenient switching between clusters in this review , and since then the utility has been supplemented by kubens (see the same repository ) for a similar switching between namespaces.
- kubeplay is another implementation of REPL, but offering to use Ruby syntax.
- zsh-kubectl-prompt is a simple script for displaying the current context and Kubernetes namespace at the zsh prompt.
PS
Read also in our blog: