kubectl - 10+ tips & tricks for Kubernetes

Опубликовано: 16 Май 2026
на канале: storagefreak
4,987
158

In this video I am sharing my favorite tips & tricks when working with K8s, using powerful kubectl tool. I woud really enjoy if you share your fav ones in the comments section! Here is my list:

1. kubectl explain - super-useful command for your everyday operations
In video: 0:05

2. kubeclt autocompletion - for the installation details run 'kubectl complete -h'
In video: 1:09

3. aliases - if you work in Bash shell you can take advantage of aliases to make your life a bit easier
In video: 1:58

4. kubectx & kubens - tools to easily switch kubectl context between clusters & namespaces. Link to the github repository https://github.com/ahmetb/kubectx
In video: 2:34

5. kube-ps1 - Modify your prompt to see which cluster & namespace is set in your current context. Github repository https://github.com/jonmosco/kube-ps1
In video: 3:49

6. kubectl exec - execute commands inside a running container
In video: 5:13

7. kubectl run - run a temporary pod and execute commands from the container
In video: 5:43
I used the image busyboxplus (https://hub.docker.com/r/radial/busyb...) since it has pre-installed curl, but you can run any image you wish that way, the command used:
kubectl run -it --rm busybox --image=radial/busyboxplus --restart=Never -- sh

8. Generate YAML files with kubectl command
In video: 6:49

9. kubectl diff - verify the changes before running kubectl apply
In video: 7:39

10. kubectl top - quick way to monitor the resources utilization
In video: 8:05

bonus: tmux & watch (I know I totally confused vertically/horizontally - sorry about that :) )
In video: 8:44
docs & installation: https://github.com/tmux/tmux/wiki

The default prefix in tmux is combination ctrl+b. For the help screen you can press ctrl+b and then ?
Shortcuts used in the video:
ctrl+b % - split the screen horizontally
ctrl+b " - split the screen vertically (I confused those in the video :) )
ctrl+b (arrow) - change active pane
ctrl+b z - move current pane to 'full screen'
ctrl+b z - undo the 'full screen'.
ctrl+b :set -g mouse on - enable mouse support
ctrl+b d - detach the current session.

wach -n1 kubectl get all - to "watch" with 1second-refresh the command 'kubectl get all'.


Remember to share your favorite ones in the comment section!