kubectl.plugin.zsh 2.58 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
50
51
52
53
54
55
56
57
58
59
60
# Namespace management
alias kgns='kubectl get namespaces'
alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'

# ConfigMap management
alias kgcm='kubectl get configmaps'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'

61
# Secret management
62
63
64
alias kgsec='kubectl get secret'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'
65
66

# Deployment management.
67
68
69
70
71
72
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'
73
74

# Rollout management.
75
76
77
alias kgrs='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
78

79
# Port forwarding
80
81
82
83
84
alias kpf="kubectl port-forward"

# Tools for accessing all information
alias kga='kubectl get all'
alias kgaa='kubectl get all --all-namespaces'
85

86
# Logs
87
88
alias kl='kubectl logs'
alias klf='kubectl logs -f'
89

90
91
92
# File copy
alias kcp='kubectl cp'

93
94
95
96
# Node Management
alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
97
alias kdelno='kubectl delete node'