kubectl.plugin.zsh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. if (( $+commands[kubectl] )); then
  2. __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
  3. if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
  4. kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
  5. fi
  6. [[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
  7. unset __KUBECTL_COMPLETION_FILE
  8. fi
  9. # This command is used a LOT both below and in daily life
  10. alias k=kubectl
  11. # Apply a YML file
  12. alias kaf='kubectl apply -f'
  13. # Drop into an interactive terminal on a container
  14. alias keti='kubectl exec -ti'
  15. # Manage configuration quickly to switch contexts between local, dev ad staging.
  16. alias kcuc='kubectl config use-context'
  17. alias kcsc='kubectl config set-context'
  18. alias kcdc='kubectl config delete-context'
  19. alias kccc='kubectl config current-context'
  20. # Pod management.
  21. alias kgp='kubectl get pods'
  22. alias kep='kubectl edit pods'
  23. alias kdp='kubectl describe pods'
  24. alias kdelp='kubectl delete pods'
  25. # get pod by label: kgpl "app=myapp" -n myns
  26. alias kgpl='function _kgpl(){ label=$1; shift; kgp -l $label $*; };_kgpl'
  27. # Service management.
  28. alias kgs='kubectl get svc'
  29. alias kes='kubectl edit svc'
  30. alias kds='kubectl describe svc'
  31. alias kdels='kubectl delete svc'
  32. # Ingress management
  33. alias kgi='kubectl get ingress'
  34. alias kei='kubectl edit ingress'
  35. alias kdi='kubectl describe ingress'
  36. alias kdeli='kubectl delete ingress'
  37. # Secret management
  38. alias kgsec='kubectl get secret'
  39. alias kdsec='kubectl describe secret'
  40. alias kdelsec='kubectl delete secret'
  41. # Deployment management.
  42. alias kgd='kubectl get deployment'
  43. alias ked='kubectl edit deployment'
  44. alias kdd='kubectl describe deployment'
  45. alias kdeld='kubectl delete deployment'
  46. alias ksd='kubectl scale deployment'
  47. alias krsd='kubectl rollout status deployment'
  48. # Rollout management.
  49. alias kgrs='kubectl get rs'
  50. alias krh='kubectl rollout history'
  51. alias kru='kubectl rollout undo'
  52. # Port forwarding
  53. alias kpf="k port-forward"
  54. # Logs
  55. alias kl='kubectl logs'
  56. alias klf='kubectl logs -f'
  57. # File copy
  58. alias kcp='kubectl cp'
  59. # Node Management
  60. alias kgno='kubectl get nodes'
  61. alias keno='kubectl edit node'
  62. alias kdno='kubectl describe node'
  63. alias kdelno='kubectl delete node'