Alias to simplify kubernetes operation

alias kgp=“kubectl get pods”

alias kgd=“kubectl get deploy”

alias kgs=“kubectl get service”

alias kgn=“kubectl get nodes”

alias kcf=“kubectl create -f”

alias kc=“kubectl”

alias kdp=“kubectl describe pods”

alias kdd=“kubectl describe deploy”

alias kds=“kubectl describe service”

alias kdn=“kubectl describe nodes”

alias kcd=“kubectl create deploy”

alias kdep=“kubectl delete pod”

alias kded=“kubectl delete deploy”

alias ked=“kubectl edit deploy”

alias kep=“kubectl edit pod”

alias kes=“kubectl edit service”

alias kcctx=“kubectl config current-context”

alias kcutx=“kubectl config use-context”

alias kcgtx=“kubectl config get-context”

1 Like

Those are a lot of aliases.

I use the following set ( which also include some other settings,that can also be found elsewhere ) :

cat << EOF > ~/.bash_aliases
alias k="kubetcl"
alias kr="kubectl run"
alias kc="kubectl create"
alias ka="kubectl apply -f"
alias kf="kubectl replace --force -f"
alias kd="kubectl describe"
alias kg="kubectl get"
alias ku="kubectl config use-context"
alias vi="vim"
EOF


cat << EOF >> ~/.bashrc
export do="--dry-run=client -o yaml"
EOF


cat << EOF > ~/.vimrc
syntax on
filetype plugin indent on
set ts=2
set sw=2
set et
set ai
EOF

I use a couple of functions too -

alias k=kubectl
alias kn=‘kubectl config set-context --current --namespace’
alias gn=‘cat .kube/config | grep namespace’
alias kg=‘k get’
alias kgd=‘k get deploy -o wide’
alias kgp=‘k get pods -o wide’
alias kgpw=‘k get pods -o wide --watch’
alias kgpa=‘k get pods -o wide -A’
alias kgn=‘k get nodes -o wide’
alias kgs=‘k get svc -o wide’
alias kge=‘k get events --sort-by=’.metadata.creationTimestamp’ | tail -8’
alias ked=‘k edit deploy’
alias kep=‘k edit pods’
alias ken=‘k edit nodes’
alias kes=‘k edit svc’
alias kc=‘k create’
alias kd=‘k describe’
alias kdelp=‘k $now delete po’
alias kdel=‘k delete’
alias ke=‘k edit’
alias kdd=‘k describe deploy’
alias kdp=‘k describe pods’
alias kdn=‘k describe nodes’
alias kds=‘k describe svc’
alias krf=‘k replace --force -f’
alias krpf=‘k replace $now -f’
alias kcf=‘k create -f’
krp() { kubectl run $1 --image=$2 $do;}
kcd() { kubectl create deploy $1 --image=$2 $do;}
export nks=‘-n kube-system’
export do=’ --dry-run=client -o yaml’
export now=’ --force --grace-period=0’
export rb=‘rolebinding’
export crb=‘clusterrolebinding’