Shortcuts to the most common kubectl actions.
k.use kube-system: switch the current working namespace to thekube-systemk.po- list pods in the current namespacek.po -n default- list pods, overwriting namespace temporarily for the commandk.po.del pod-name- delete pod pod-namek.po.y pod-name- show filtered, less cluttered kubectl-neat-like yaml representation (or original yaml with -f/--full option)k.po.x pod-name uptime- execute "uptime" command in the container, returning stdout or attach to a shell if no command is specifiedk.scale mydeployment=2: scale deployment, replicaset, statefulset or replicationcontroller to 2 replicask.logs pods/my-pod-name -f: return 20 most recent logs of all containers in a pod and follow the streams ("pods/" prefix optional)k.sec.y secret-name: return YAML representation of secret named secret-namek.no.top: current near-realtime CPU and RAM usage of nodes in mCPU and memory units (current cpu/mem usage)k.no.res: resources allocated (requests and limites) by workloads for each node (node utilization)k.no.x node-name: SSH into the node using public node IP andKUBESHORT_DEFAULT_USERuserk.no.dr -C my-node-name: completely drain node (ignoring pods with emptyDir, daemonsets and stray pods: --force --delete-local-data --ignore-daemonsets)k.ctx other-cluster: switch to other-cluster context (instead of kubectl use-context)k.ctx: see the current contextk.apl.f file.yaml: kubectl apply -f file.yamlk get pods: just likekubectl get pods, with-n current-namespaceis auto-appended
See the source code or ./_ks.py -h output for more shortcuts.
# use your custom bin directory (optional)
mkdir ~/bin
export PATH="$HOME/bin/:$PATH"
# move to your bin directory
chmod +x ./_ks.py
cp ./_ks.py ~/bin/
# let it create symlinks to itself in your bin directory
_ks.py install-symlinks -t ~/bin/You can customize these environmental variables:
KUBESHORT_CUR_NS_PATH: path to store the current, working namespace name (default /tmp/.k8s-cur-ns)KUBESHORT_ALLOW_SHORT: whether to create also shorter versions of common resources (e.g. "cj" for "cronjob", default "1")KUBESHORT_DEFAULT_TAIL: number of log lines to return (default 20)KUBESHORT_DEFAULT_USER: default user when SSH'ing into a node (default ubuntu)
A wrapper around logcli to automatically create and teardown port-forwarding and fetch common log labels.
This tool was made to help me save time writing long, repetitive kubectl commands.
It shouldn't be considered fully-featured kubectl replacement, following official design documentations or implementing every possible resource and CRD.
The purpose is simply to make life easier by simplifying most-commonly made actions on common resources.
That said, I am open for contributions and suggestions. Python is not my primary language so I am probably also not following its best practices. :P
GNU GPL v3