A compilation of useful functions for working with kubernetes
In the heat of the battle we need to be fast so for keep things going here are some principles
- kiss Keep it simple! righT?
- provide visual aid preferable using fuzzy finder fzf command
- echo the command you're executing others can learn and re-use
- use https://github.com/reconquest/shdoc to build this README.md
shdoc kubetools.sh >README.md
Add this file to your .profile .bashrc .zshrc
...
source $PATH_TO_FILE/kubetools.sh
...
- kpo()
- ke()
- kno()
- kdp()
- kd()
- kg()
- kppn()
- kppnn()
- knaws()
- knawsall()
- kds()
- kss()
- kst()
- ksta()
- kfmds()
- krun()
- krunbrowse()
- knew()
- kproxy()
a shortcut for: get pods
$ kpo -o wide
- ... (all): the options you want ie: -o wide
- a list of pods
a shortcut for: get events timestamp sorted
$ ke
- ... (all): the options you want ie: -l wide
- a list of events
a shortcut for: get nodes
$ kno -o wide -l kafka-connect-dedicated=trues
- ... (all): the options you want ie: -o wide
- a list of nodes
a shortcut for: get deployments
$ kdp -o wide
- ... (all): the options you want ie: -o wide
- a list of deployments
a shortcut for: describe
$ kd deployment -l app=kafka
- ... (all): the options you want ie: deployments
- a list of yaml
a shortcut for: get
$ kg pods -l app=kafka
- ... (all): the options you want ie: pods
- a list of resources or a single resource
list all the pods in a node picking one node or passing the node name as an argument
$ kppn ip-172-18-4-100.ap-northeast-1.compute.internal
$ kppn
- list of pods
list all the pods in a node picking one pod from the current namespace
$ kppnn
- list of pods
get nodename given your aws ids
$ knaws i-044cb8a4d984cba35
- ... (all): the options you want ie: -o wide
- ip-172-18-6-113.ap-northeast-1.compute.internal - aws:///ap-northeast-1d/i-402kr4t2j546hvy23
get all aws ids from your nodes
$ knawsall
- ... (all): the options you want ie: -o wide
- ip-172-18-6-113.ap-northeast-1.compute.internal - aws:///ap-northeast-1d/i-402kr4t2j546hvy23
a shortcut for: get daemonsets
$ kds -o wide
- ... (all): the options you want ie: -o wide
- a list of daemonsets
a shortcut for: get statefulsets
$ kss -o wide
- ... (all): the options you want ie: -o wide
- a list of statefulsets
Get a status count from the current namespace
$ kst
- ... (all): the options you want
- pod status 5 Completed 5 CrashLoopBackOff 38 Running
Get a status count from all namespaces
$ ksta
- ... (all): the options you want
- pod status 5 Completed 5 CrashLoopBackOff 38 Running
find missing daemonsets pods
$ kfmds filebeatlogz-filebeat
- $1 (name): od the daemonset
- ... (all): the options you want
- Node ip-172-27-2-72.ec2.internal is not running a pod from the daemonset filebeatlogz-filebeat
Run an epheremal pod with the image you want
$ krun python:3-slim bash --env=VAR1=value1 --env=VAR2=value2 --port=8080
- $1 (imagename):
- $2 (command):
- run an ephemeral pod
Run an epheremal pod with the image you want browsing from local docker images If you have a file called .docker-images in your home directory it will use that
$ krunbrowse
Run an isolated kubernetes context using kubie
$ knew
Run an epheremal pod to proxy to internal aws host
$ kproxy kproxy ads-monetization-airflow-database.cluster-crevvby4h2ik.us-east-1.rds.amazonaws.com 5432
- $1 (hostname):
- $2 (port):
- run tcp-proxy