kubectl.plugin.zsh 2.12 KB
Newer Older
1
2
if (( $+commands[kubectl] )); then
    __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
Patrick Stadler's avatar
Patrick Stadler committed
3

4
5
6
    if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
        kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
    fi
7

8
    [[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
9

10
    unset __KUBECTL_COMPLETION_FILE
Patrick Stadler's avatar
Patrick Stadler committed
11
fi
12

Shawn Milochik's avatar
Shawn Milochik committed
13
# This command is used a LOT both below and in daily life
14
15
alias k=kubectl

16
# Apply a YML file
17
alias kaf='kubectl apply -f'
18

19
# Drop into an interactive terminal on a container
20
alias keti='kubectl exec -ti'
21
22

# Manage configuration quickly to switch contexts between local, dev ad staging.
23
24
25
26
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'
27
28

# Pod management.
29
30
31
32
alias kgp='kubectl get pods'
alias kep='kubectl edit pods'
alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
33

34
35
36
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='function _kgpl(){ label=$1; shift; kgp -l $label $*; };_kgpl'

37
# Service management.
38
39
40
41
alias kgs='kubectl get svc'
alias kes='kubectl edit svc'
alias kds='kubectl describe svc'
alias kdels='kubectl delete svc'
42

43
# Ingress management
44
45
46
47
alias kgi='kubectl get ingress'
alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress'
48

49
# Secret management
50
51
52
alias kgsec='kubectl get secret'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'
53
54

# Deployment management.
55
56
57
58
59
60
alias kgd='kubectl get deployment'
alias ked='kubectl edit deployment'
alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
61
62

# Rollout management.
63
64
65
alias kgrs='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
66

67
68
69
# Port forwarding
alias kpf="k port-forward"

70
# Logs
71
72
alias kl='kubectl logs'
alias klf='kubectl logs -f'
73

74
75
76
# File copy
alias kcp='kubectl cp'

77
78
79
80
# Node Management
alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
81
alias kdelno='kubectl delete node'