"kube-prompt" - Commands Auto Complete Shell for Kubernetes

kubeprompt shell kubernetesAfter introducing the kube-shell couple of articles earlier, we now get to another great shell for kubernetes, called kube-prompt. In this article we again use Minikube local cluster for demonstration, but we will this time use KVM instead of VirtualBox. You can off course also run kube-prompt in VirtualBox if you like that better, but there are quite few reasons to go with KVM. Most important of them: VirtualBox gives your kernel tainted flag due to kernel driver that is out of tree. Some people have reported kernel instability with kmods of VirtualBox, and since kernel is tainted with them, your bug reports won't be seen as first priority. KVM is in mainline kernel so no such problem with it. We are going to use Ubuntu for this article, on my backup laptop, the X220T.

Installing KVM

Obviously, the first thing we need is KVM installation.

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

To be able to use the libvirt without trouble, you need to add your user to libvirt group. Being logged in as your user, run this command

sudo adduser `id -un` libvirt

And finally to test your KVM installation, run this command

kvm-ok

Should give you something like this

INFO: /dev/kvm exists
 KVM acceleration can be used

Installing the kubectl, minikube and docker-machine-driver-kvm

We need to install all the binaries. Kubectl is off course first among them, so we install it with following 3 commands.

curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/kubectl

Then add executable bit and move it to path

chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl

Next is minikube. Latest version is 0.22 as of time of writing. We can install it with this one liner

curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.22.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

In order to have minikube run on KVM, we need docker-machine-kvm driver. Here is how to download it.

curl -LO https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04

And again, executable bit and move to the path

chmod +x docker-machine-driver-kvm-ubuntu16.04

sudo mv docker-machine-driver-kvm-ubuntu16.04 /usr/local/bin/docker-machine-driver-kvm

Bringing up the cluster and run with KVM by default

The binaries are in place but minikube by default looks for VirtualBox. So we can use this command to change default to KVM:

minikube config set vm-driver kvm

After it we can run command that creates cluster

minikube start

Output should be similar to this

Installing the kube-prompt

And finally, now that we have a cluster running, we can install the kube-prompt

wget https://github.com/c-bata/kube-prompt/releases/download/v1.0.1/kube-prompt_v1.0.1_linux_amd64.zip

We need unzip, so if you don't have it, now is time to install it.

sudo apt install unzip

And then let's unzip the archive.

unzip kube-prompt_v1.0.1_linux_amd64.zip

Next move is to add executable bit and move it to the path

chmod +x kube-prompt
 sudo mv kube-prompt /usr/local/bin/kube-prompt

Using the kube-prompt

Entering kube prompt is done simply by typing kube-prompt.

From there we get the auto-completion options, and unlike kube-shell, there is no need to type kubectl command. Make no mistake, they kubectl is still needed, but kube-prompt just types it automatically. Following commands will get you the hello-minikube test deployment and service created:

kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.7 --port=8080
kubectl expose deployment hello-minikube --type=NodePort

Here are some examples for kube-prompt:

get deployments


get pods

exec


get namespaces

get pods --all-namespaces


describe endpoints

As we see, the kube-prompt is somewhat similar to kube-shell we introduced earlier. The main difference is that you don't have to type kubectl. In fact, if you type it, it will throw error, as it will be parsed as kubectl. Kubernetes is becoming easy and productive with kube-prompt and other shells, but they all still need polish as they are rough at edges. Goals of kube-prompt team are outlined on github page. They plan on supporting most of the kubernetes commands which is praise worthy. For now, I will just keep using plain kubectl as none of the shells are production ready yet. Thank you for reading, this is all for this article.

About Mihajlo Milenovic

Miki is a long time GNU/Linux user, Free Software advocate and a freelance system administrator from Serbia. Got introduced to GNU/Linux in year 2003 on old AMD Duron computer, and since than always eager to learn new stuff about this system. From 2016 writes for Linoxide to share his experiences with wider audience

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.