Skip to content

Instantly share code, notes, and snippets.

@ashwinrs
Created January 3, 2020 16:51
Show Gist options
  • Save ashwinrs/a3132573ad641674401c552576eaa82d to your computer and use it in GitHub Desktop.
Save ashwinrs/a3132573ad641674401c552576eaa82d to your computer and use it in GitHub Desktop.
Kubernetes aliases
alias k='kubectl'
alias kx='kubectx'
alias khelp='echo n:nodes, p:pods, s:services, d: deployment, con:context, i:ingress, ns:namespace, map:configmaps, sec:secret, roll:rollout, kx=kubectx'
### Drop into an interactive terminal on a container
alias kexec='f() { kubectl exec -it "$@" -- bash; }; f'
### Pod management.
alias kp='kubectl get pods'
alias kpwatch='kubectl get pods --watch'
alias kpwide='kubectl get pods -o wide'
alias kpedit='kubectl edit pods'
alias kpdes='kubectl describe pods'
alias kpdel='kubectl delete pods'
# get pod by label: kgpl "app=myapp" -n myns
# alias kplable='kgp -l'
### Service management.
alias ks='kubectl get svc'
alias kswatch='kubectl get svc --watch'
alias kswide='kubectl get svc -o wide'
alias ksedit='kubectl edit svc'
alias ksdes='kubectl describe svc'
# alias ksdel='kubectl delete svc'
### Deployment management.
alias kd='kubectl get deployment'
alias kdwatch='kubectl get deployment --watch'
alias kdwide='kubectl get deployment -o wide'
alias kdedit='kubectl edit deployment'
alias kddesc='kubectl describe deployment'
# alias kddel='kubectl delete deployment'
alias kdscale='kubectl scale deployment'
alias kdrollout='kubectl rollout status deployment'
# Rollout management.
alias kroll='kubectl get rs'
alias kroll_hist='kubectl rollout history'
alias kroll_undo='kubectl rollout undo'
# Node Management
alias kn='kubectl get nodes'
alias knedit='kubectl edit node'
alias kndes='kubectl describe node'
# alias kndel='kubectl delete node'
### Ingress management
alias ki='k get ingress'
alias kiedit='k edit ingress'
alias kides='k describe ingress'
### Namespace management
alias kns='k get namespace'
alias knedit='k edit namespace'
alias knsdesc='k describe namespace'
### ConfigMap management
alias kmap='kubectl get configmaps'
alias kmapedit='kubectl edit configmaps'
alias kmapdesc='kubectl describe configmaps'
# Secret management
alias ksec='kubectl get secret'
alias ksecdesc='kubectl describe secret'
# All information
alias kall='kubectl get all'
alias kall_ns='kubectl get all --all-namespaces'
# Logs
alias klog='kubectl logs'
alias klogf='kubectl logs -f'
# File copy
alias kcp='kubectl cp'
# Context
# https://github.com/ahmetb/kubectx
alias kcon='kubectx'
alias kconswitch='kubectx $1'
alias kconswitch_back='kubectx -'
alias kconrename='kubectx $1=$2'
# Cronjob
alias kcrn='kubectl get cronjob'
alias kcrnd='kubectl describe cronjob' #<cron_job>
alias kcrnlog='kubectl get log' #<cron_job>
alias kcrndel='kubectl delete cronjob' #<cron_job>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment