kubectl.plugin.zsh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # General aliases
  21. alias kdel='kubectl delete'
  22. alias kdelf='kubectl delete -f'
  23. # Pod management.
  24. alias kgp='kubectl get pods'
  25. alias kgpw='kgp --watch'
  26. alias kgpwide='kgp -o wide'
  27. alias kep='kubectl edit pods'
  28. alias kdp='kubectl describe pods'
  29. alias kdelp='kubectl delete pods'
  30. # get pod by label: kgpl "app=myapp" -n myns
  31. alias kgpl='kgp -l'
  32. # Service management.
  33. alias kgs='kubectl get svc'
  34. alias kgsw='kgs --watch'
  35. alias kgswide='kgs -o wide'
  36. alias kes='kubectl edit svc'
  37. alias kds='kubectl describe svc'
  38. alias kdels='kubectl delete svc'
  39. # Ingress management
  40. alias kgi='kubectl get ingress'
  41. alias kei='kubectl edit ingress'
  42. alias kdi='kubectl describe ingress'
  43. alias kdeli='kubectl delete ingress'
  44. # Namespace management
  45. alias kgns='kubectl get namespaces'
  46. alias kens='kubectl edit namespace'
  47. alias kdns='kubectl describe namespace'
  48. alias kdelns='kubectl delete namespace'
  49. # ConfigMap management
  50. alias kgcm='kubectl get configmaps'
  51. alias kecm='kubectl edit configmap'
  52. alias kdcm='kubectl describe configmap'
  53. alias kdelcm='kubectl delete configmap'
  54. # Secret management
  55. alias kgsec='kubectl get secret'
  56. alias kdsec='kubectl describe secret'
  57. alias kdelsec='kubectl delete secret'
  58. # Deployment management.
  59. alias kgd='kubectl get deployment'
  60. alias kgdw='kgd --watch'
  61. alias kgdwide='kgd -o wide'
  62. alias ked='kubectl edit deployment'
  63. alias kdd='kubectl describe deployment'
  64. alias kdeld='kubectl delete deployment'
  65. alias ksd='kubectl scale deployment'
  66. alias krsd='kubectl rollout status deployment'
  67. # Rollout management.
  68. alias kgrs='kubectl get rs'
  69. alias krh='kubectl rollout history'
  70. alias kru='kubectl rollout undo'
  71. # Port forwarding
  72. alias kpf="kubectl port-forward"
  73. # Tools for accessing all information
  74. alias kga='kubectl get all'
  75. alias kgaa='kubectl get all --all-namespaces'
  76. # Logs
  77. alias kl='kubectl logs'
  78. alias klf='kubectl logs -f'
  79. # File copy
  80. alias kcp='kubectl cp'
  81. # Node Management
  82. alias kgno='kubectl get nodes'
  83. alias keno='kubectl edit node'
  84. alias kdno='kubectl describe node'
  85. alias kdelno='kubectl delete node'