One of the most valuable features of the
kubectl utility is its plugins.
So, in this post, we will install the Krew -
kubectl's plugins manager, and will take a look at the list of the plugins, that are used by me during work.
kubectl got its own plugins manager, the Krew.
It has a plugins repository used to install and upgrade plugins.
On the Arch Linux
krew can be installed from AUR:
$ yay -S krew
Update its packages list:
$ kubectl krew update
Look for a plugin, for example the
$ kubectl krew search topology NAME DESCRIPTION INSTALLED topology Explore region topology for nodes or pods no
$ kubectl krew install topology Updated the local copy of plugin index. Upgrades available for installed plugins: * rbac-tool v1.2.1 -> v1.3.0 Installing plugin: topology Installed plugin: topology \ | Use this plugin: | kubectl topology | Documentation: | [https://github.com/bmcustodio/kubectl-topology](https://github.com/bmcustodio/kubectl-topology) /
$ kubectl topology help Provides insight into the topology of a Kubernetes cluster. Usage: kubectl-topology [command] Available Commands: help Help about any command node Provides insight into the distribution of nodes per region or zone. pod Provides insight into the distribution of pods per region or zone.
At the end of this post I’ll add a couple of links with a similar plugins list, and here below let’s take a look at the best, as for me, plugins that I’m using during work.
Let’s start from the
kubectl-topology plugin that allows to display all cluster's WorkerNodes, their regions, and pods located on each node:
kubectl-resources plugin can display extended information about limits and resources used by pods on WorkerNodes.
Install with Go:
$ go get github.com/howardjohn/kubectl-resources
kubectl-free plugin is similar to the
free utility in Linux - it will display information about used and available resources on WorkerNodes.
Install it by downloading an archive from the release page, unzip, and copy to the
$ cd /tmp/ $ wget [https://github.com/makocchi-git/kubectl-free/releases/download/v0.2.0/kubectl-free_0.2.0_Linux_x86_64.zip](https://github.com/makocchi-git/kubectl-free/releases/download/v0.2.0/kubectl-free_0.2.0_Linux_x86_64.zip) $ unzip kubectl-free_0.2.0_Linux_x86_64.zip $ sudo cp kubectl-free_0.2.0_Linux_x86_64/kubectl-free /usr/local/bin/
And run it:
kubecolor is very useful to make kubectl's output more readable by colonizing it.
Install with Go:
$ go install github.com/dty1er/kubecolor/cmd/kubecolor@latest
Add an alias to the
And its result:
An improved variant of the
kubectl --watch. The project's page is here>>>.
$ git clone [https://github.com/lee0c/kubectl-watch.git](https://github.com/lee0c/kubectl-watch.git) $ cd kubectl-watch $ chmod +x kubectl-watch $ sudo mv kubectl-watch /usr/local/bin/
$ kubectl plugin list The following kubectl-compatible plugins are available: /usr/local/bin/kubectl-watch …
An advanced logs viewer. Similar to the
kubectl logs -f, but can tail logs from all pods in a namespace. More details here>>>.
$ go install github.com/ivkalita/kubectl-clogs/cmd/kubectl-clogs@latest
And check logs from the istio-system namespace:
kubectl-who-can is used to display RBAC permissions and accesses.
Install with Krew:
$ kubectl krew install who-can
And check who is able to delete pods in the default namespace:
kubectl-rolesum is also used to work with the Kubernetes RBAC to check permissions.
$ kubectl krew install rolesum
And check permissions for the kiali-service-account ServiceAccount in the istio-system namespace:
ketall will display indeed all resources including Secrets, ServiceAccount, Roles, Binding, and so on, and not only Pods, Services, Daemonsets, Deployments, and ReplicaSets, as it is when using the
kubectl get all.
$ kubectl krew install get-all
An example of the
kubectl get all command's output:
And with the
kubectl-status can display extended information about pods' statuses, nodes, deployments, services, and so on.
$ kubectl krew install status
And check Kubernetes WorkerNodes status with the
role: data-workers label set:
Pod-Dive will display information about a Kubernetes Pod - its WorkerNode, a namespace, containers in that pod, and other pods, that are running on the same WorkerNode.
$ kubectl krew install pod-dive
And check a Pod:
kubectl-janitor - a "cleaner" for a Kubernetes cluster. Can find problematic resources, such as unscheduled pods, failed jobs, volumes, etc.
$ kubectl krew install janitor
And find all pods that are not scheduled to a WorkerNode:
And the last plugin for today -
Actually, there are a lot of plugins to simply work with
kubectl's contexts, but I'm using dedicated files for clusters instead of dedicated contexts:
$ ls -1 ~/.kube/ | grep kubeconfig dev-1–18.kubeconfig prod-1–18.kubeconfig stage-1–18.kubeconfig test-1–18.kubeconfig
For a faster switch between them, we can use the
kubectl-cf plugin, that will work via creating symlinks to the
Pay attention, that all files must have the
Install it — clone its repository, build, and copy to the
$ git clone [https://github.com/spongeprojects/kubectl-cf.git](https://github.com/spongeprojects/kubectl-cf.git) $ cd kubectl-cf/ $ go build -o kubectl-cf $ sudo cp kubectl-cf /usr/local/bin/
- awesome-kubectl-plugins — a curated list of awesome kubectl plugins
- Top 179 Kubectl Plugins Open Source Projects on Github
Originally published at RTFM: Linux, DevOps, and system administration.