Cool Kubernetes command line plugins
Lately, I have been using my old set of kubectl command over and over, and I think it’s time to try around in hope to find some good tools that might come in handy for my day to day work.
Kubectl have a plugins management that we can use to install a plugin (like brew) called Krew
Installation
krew can be installed easily using brew 😆
brew install krew
and after we installed it, we can list available plugins via
kubectl krew search

in this blog, I will only tried the one compatible with my machine (sadly, not all plugins support Mac m1 yet)
to install the plugin, simply go with
kubectl krew install <plugin-name>
access-matrix
kubectl access-matrix --namespace default
access-matrix is very useful plugin to see the permission of your subject.
it can use to view access to the resource in the namespace, or review access of another user, or service account and display it in an easy to understand format (icon)

mtail
kubectl mtail -k <label-selector> # -k is to add colored to different podkubectl mtail -k app=prometheus
mtail is super useful when you want to tail and follow the logs from multiple pods at the same time using selectors

once we run mtail it will show the logs of all pods in different colors using -k

get-all
kubectl get-all
there is no simpler definition of this plugin than get ALL!
as opposed to
kubectl get all
that only get core resource such as pod, deployment, daemonset, etc
get-all literally get all, including all of the mentioned above and your CRDs and operators

you can also adjust the scope, exclude, or get-all in only namespace.
graph
kubectl graph <resource>
kubectl graph ns
graph is used for visualizing Kubernetes resources and their relationship

images
kubectl images
images shows all the images used in the cluster in a readable table format

neat
kubectl get pod mypod -o yaml | kubectl neat
neat clean your resource yaml into vanilla version of it.
it removes additional fields such as status, creation time, uid, etc
this is helpful in development process and handy in replication of resource into another ns


pod-lens
k pod-lens #interactive command
Find related workloads, namespace, node, service, configmap, secret,
ingress, PVC, HPA and PDB by pod name and display them in a tree and table.
Find more information at: https://pod-lens.guoxudong.io/


prune-unused
kubectl prune-unused
useful quick command to run and clear unused resource in the cluster
Prune unused configmaps/secret resources from a given namespace. It
checks against all resources from mounted volumes, env and envFrom and
imagePullSecrets.
score
kubectl score score <resource-file.yaml>
score is used to check the configuration of your resource yaml file
I find this plugin super helpful and CI/CD friendly
This should be put into you DevOps workflow immediately

# Fun plugins in found
snap: delete half of the pods in the cluster. Oops!
There are still more cool stuffs in the list that I did not cover, If I have a mood for it I might compile another version of them in the next blog. also, lots of plugins are not supported in m1, so I might miss tons of cool plugins that I should try.
Hope you guys enjoy this, and If you know the one that I should try, leave me a comment.
Adios!