Chapter 7. Kubernetes Power Tools
My mechanic told me, “I couldn’t repair your brakes, so I made your horn louder.”
Steven Wright
People always ask us, “What about all these Kubernetes tools? Do I need them? If so, which ones? And what do they all do?”
In this chapter, we’ll explore a small part of the landscape of tools and utilities that help you work with Kubernetes. We’ll show you some advanced techniques with kubectl
, and a few useful utilities such as jq
, kubectx
/kubens
, kube-ps1
, Click, kubed-sh
, Stern, and BusyBox.
Mastering kubectl
We’ve already met kubectl
, starting in Chapter 2, and as it’s the primary tool for interacting with Kubernetes, you may already be comfortable with the basics. Let’s look at some more advanced features of kubectl
now, including some tips and tricks that may be new to you.
Shell Aliases
One of the first things that most Kubernetes users do to make their lives easier is to create a shell alias for the kubectl
command. For example, we have the following alias set up in our .bash_profile or .zshrc files:
alias
k
=
kubectl
Instead of having to type out kubectl
in full for every command, we can just use k
:
k get pods
If there are some kubectl
commands that you use a lot, you might like to create aliases for them too. Here are some possible examples:
alias
kg
=
kubectl
get
alias
kgdep
=
kubectl
get
deployment
alias
ksys
=
kubectl
--namespace
=
kube-system
alias
kd
=
kubectl
describe
Google engineer Ahmet Alp Balkan has worked out a logical system of aliases ...
Get Cloud Native DevOps with Kubernetes, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.