Kubernetes is…. Quite a thing, to say the least ! 😅 Even if their conceptors did a great job at making the kubectl
cli as usable as possible, it can sometimes be a pain to be productive with it, read outputs, or do repetitive tasks. That’s why I wrote this small Quality of life improvements post: to regroup some install steps you might have missed, give you some useful 3rd party tools or maybe even give you tips a step ahead.
{{profileFile}}
with your profile file path. Usually, it’s ~/.zshrc
for ZSH, and ~/.bashrc
for bash, but feel free to put all this stuff in a separate file you’ll include from your main profile.kubectl
auto-complete
Autocomplete is nice, and a real time saver. It avoids typos, and it’s quite satisfying to type a complete command in 4 keystrokes and a couple of tab
s correctly placed. (even if I’m always unsure when relying on my browser’s autocomplete for https://analytics.google.com 😑).
But for this one, I can only say one thing, and you have no excuses:
So, short stories short, and depending on your shell, type in:
|
|
All the (bad) flavours come from the natural world.
|
|
kubecolor
: prettier kubectl
commands outputs with colors
|
|
If the command above did not worked, then you may have a problem with your $GOPATH
or $GOHOME
environment variables. If none are set, then the package was installed in ~/go/bin
. Either fix your vars or add ~/go/bin
to your $PATH
.
|
|
Finally, you could either use kubecolor
instead of kubectl
, or alias kubectl
as kubecolor
with the following code sample:
|
|
I noticed some little things does not work well with kubecolor
. That’s why the script above let you use the original kubectl
command through kubectll
. For instance, I noticed that some commands prompting user input (so using stdin), such as kubectl login
, don’t work.
So, if you try a command that seems to not work as expected, or stay stuck, fall back to kubectll
.
helm
: a kubernetes stack template repository
Helm is a convinient way to use or share configurable kubernetes stacks. For example, it may allow to install easily a front-end, with its API and a database, in a single template, in which you can inject your specific configuration (PVC, ports, environment, etc…).
To install helm, run the following command:
|
|
krew
: a kubectl
plugins manager
krew is a nice small plugin manager for your kubectl
command. At the time of writing, it has
129 plugins available, including some pretty convinient to restart pods, login using OpenId, check the state of your cluster, and more.
To install krew, run the following: (taken from the docs)
Think about replacing
{{profileFile}}
with your actual zsh or bash profile
|
|
One ring to rule them all
For this one, I plead guilty of not using it enough, but it contains a lot of useful knowledge and possible solutions of most of your problems.
You guessed it, I’m talking about documentation. (because it would be an insult to tell you that StackOverflow is a thing.)
Read it carefully. Take time to understand it and its underlying concepts. Don’t use tools you don’t know how they work. Because when things breaks, your knowledge of what and how it broke will help you to solve the problem quickly and without damages. So, read the documentation of your containers, your helm charts, your kubernetes network layer, and, of course, kubernetes and docker themselves.