Member-only story

My Most Used Commands for Kubernetes

Matt Kornfield
3 min readMar 10, 2023

And how you can find yours

Photo by Andras Vas on Unsplash

Thought it might be a silly exercise to see which commands I’ve run the most, maybe they’ll be helpful for your Kubernetes journey.

Let’s take a look!

How Do You Query for Them?

The history command will spit out your old commands but it also includes nubers to refer back to the command. I was able to instead grep my ~/.bash_history file for certain commands, and then cut the output so that I could see what commands I issued the most by the relevant pieces.

The Results

Just the first field, i.e. which command do I use most, kubectl or its alias, k (which I highly recommend to save yourself some typing)

cat ~/.bash_history | grep -v '#' | grep -E '(^k |^kubectl)' \
| cut -d" " -f1 | sort | uniq -c | sort
177 kubectl
3052 k

Clearly k wins.

Now for the second field

cat ~/.bash_history | grep -v '#' | grep -E '(^k |^kubectl)' \
| cut -d" " -f1-2 | sort | uniq -c | sort
32 k run
36 k top
66 k port-forward
74 k config
80 kubectl get <--- same as `k get`
106 k exec
124 k delete
289 k describe
339 k logs
1902 k get

--

--

Matt Kornfield
Matt Kornfield

Written by Matt Kornfield

Today's solutions are tomorrow's debugging adventure.

No responses yet