Hello! This gist goes with this video, which covers shortcuts and strategies for working with the K8s command line. You can see all of my videos on YouTube at https://adrian.goins.tv.
I use Fish as my shell, but I know that a lot of people are using Bash. Here are two ways to concatenate config files for kubectl
into the KUBECONFIG
environment variable. If you're using zsh
or tcsh
you'll know how to convert these to your shell's format.
You can call these from your shell init file, or if you want to temporarily disable a script, append .bak
or .disabled
to its extension and run the script manually.
You can even hotkey it on something like the Elgato Stream Deck.
#!/usr/local/bin/fish
set -gx KUBECONFIG (echo (find ~/.kube -type f -name config.\*.yaml) | sed 's/[[:space:]]/:/g')
#!/bin/bash
export KUBECONFIG=$(echo $(find ~/.kube -type f -name config.\*.yaml) | sed 's/[[:space:]]/:/g')
These are the aliases that I use most frequently:
alias kc kubectl
alias kd 'kubectl describe'
alias kdno 'kubectl describe nodes'
alias kdns 'kubectl describe namespaces'
alias kdpo 'kubectl describe pods'
alias kex 'kubectl exec -i -t'
alias kg 'kubectl get'
alias kga 'kubectl get all'
alias kgd 'kubectl get deploy'
alias kgi 'kubectl get ingress'
alias kgno 'kubectl get nodes'
alias kgns 'kubectl get namespaces'
alias kgow 'kubectl get -o=wide'
alias kgoy 'kubectl get -o=yaml'
alias kgpo 'kubectl get pods'
alias kgs 'kubectl get service'
alias klo 'kubectl logs -f'
alias kp 'kubectl proxy'
alias krm 'kubectl delete'
alias krmpo 'kubectl delete pods'
alias kc=kubectl
alias kd='kubectl describe'
alias kdno='kubectl describe nodes'
alias kdns='kubectl describe namespaces'
alias kdpo='kubectl describe pods'
alias kex='kubectl exec -i -t'
alias kg='kubectl get'
alias kga='kubectl get all'
alias kgd='kubectl get deploy'
alias kgi='kubectl get ingress'
alias kgno='kubectl get nodes'
alias kgns='kubectl get namespaces'
alias kgow='kubectl get -o=wide'
alias kgoy='kubectl get -o=yaml'
alias kgpo='kubectl get pods'
alias kgs='kubectl get service'
alias klo='kubectl logs -f'
alias kp='kubectl proxy'
alias krm='kubectl delete'
alias krmpo='kubectl delete pods'
Ahmet Alp Balkan has created kubectx and kubens, which dramatically simplify common actions with kubectl
.