-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_k8s
77 lines (58 loc) · 1.76 KB
/
.bash_k8s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
. <(kubectl completion bash)
alias k='kubectl'
alias kg='kubectl get "$@"'
alias kd='kubectl describe "$@"'
# pods
alias kgpo='kubectl get po -o wide'
alias kdpo='kubectl describe po "$@"'
# nodes
alias kgno='kubectl get no'
alias kdno='kubectl describe no "$@"'
kgnoz() { # nodes with zone
kubectl get nodes -o json | \
jq '.items[] as $item | {
name: $item.metadata.name,
zone: $item.metadata.labels["failure-domain.beta.kubernetes.io/zone"],
}'
}
# cronjobs
alias kgcj='kubectl get cj'
# configmaps
alias kgcm='kubectl get cm'
alias kdcm='kubectl describe cm "$@"'
# daemonsets
alias kgds='kubectl get ds'
# deployments
alias kgdep='kubectl get deploy'
# replicasets
alias kgrs='kubectl get rs'
# statefulsets
alias kgsts='kubectl get sts'
# services
alias kgsvc='kubectl get svc'
alias kdsvc='kubectl describe svc "$@"'
# secrets
alias kgsecrets='kubectl get secrets'
alias kgsecret='kubectl get secret -o jsonpath="{.data}" "$@"'
# volumes
alias kgpv='kubectl get pv'
alias kgpvc='kubectl get pvc'
alias kdpv='kubectl describe pv "$@"'
alias kdpvc='kubectl describe pvc "$@"'
kgpvz() { # pv w/ zone
kubectl get pv -o json | \
jq '.items[] as $item | {
name: $item.metadata.name,
claimRef: "\($item.spec.claimRef.namespace)/\($item.spec.claimRef.name)",
zone: $item.metadata.labels["failure-domain.beta.kubernetes.io/zone"],
phase: $item.status.phase,
}'
}
# logs
alias kl='kubectl logs --tail=100 -f "$@"'
# events
alias kgev='kubectl get events --sort-by=.metadata.creationTimestamp'
# debug containers
alias knetshoot='kubectl run trott-netshoot --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
alias kredis='kubectl run trott-redis --rm -i --tty --image bitnami/redis:4.0.11-debian-9 -- /bin/bash'