Peter Jausovec
3 min readMay 10, 2022

--

AhmetB started an excellent thread yesterday where he asked people to share a Kubernetes CLI (kubectl) tip that they think a lot of users don’t know about.

There are so many excellent tips I decide to collect the most interesting ones in a single post. The first thing that I typically do when I am on a new machine is to set the alias for kubectl:

alias k=kubectl

If you’re working with Kubernetes, you’ll be typing kubectl a lot, so why not make it shorter.

Enjoy the tips below and let us know if you have any other tips you want to share. Here are all the tips in no particular order.

1. Set up load-based horizontal pod autoscaling on your Kubernetes resources

By @pixie_run

kubectl autoscale deployment foo --min=2 --max=10

2. Create a new job from a cronjob

By @mauilion

kubectl create job --from=cronjob/<name of cronjob> <name of this run>

3. Enumerate permissions for a given service account

By @mauilion

kubectl -n <namespace> auth can-i --list --as system:serviceaccount:<namespace>:<service account name>

4. Annotate resources

--

--