-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
297 lines (284 loc) · 11.6 KB
/
.aliases
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# JUMP
alias cd..='cd ..'
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
# MISC
alias h="history --show-time='%d.%h - %H:%M:%S '"
alias a='bat'
alias r='ranger'
alias l='ls -lrthp'
alias tre='exa --long --tree --color-scale'
alias grid='exa --recurse -L 2 -l --grid'
alias ap='ansible-playbook'
alias tf='terraform'
alias bs='base64 --decode'
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
alias v='vault'
alias g='gcloud'
alias ld='linkerd'
alias publicip='curl ipinfo.io/ip'
alias privateip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
alias dig='dig +short'
alias duf='duf -hide special'
alias rgg='vim $(rg . | fzf | cut -d ":" -f 1)'
# GIT
alias gs='git status'
alias dif='git diff'
alias gb='git symbolic-ref --short HEAD'
alias gf='git fetch origin'
alias gmr='git merge origin master'
alias gbr='git branch -av'
alias g1='git log -1'
alias gl="git log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'"
alias gll='git log --stat --abbrev-commit'
alias gld='git log --pretty=format:%cd --date=short | uniq -c'
alias gplom='git pull origin master'
alias grb='git fetch origin && git rebase origin master'
alias gm='git checkout master; git reset --hard origin/master; gplom'
alias gc='git checkout -b'
alias gcm='git checkout master'
alias gac='git add . && git commit -m'
alias gp='git push'
alias gchp='git cherry-pick'
# DOCKER
alias dps='docker ps --all --format "table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}"'
alias di='docker images'
alias dsp='docker system prune'
alias dis='docker images --format '{{.Size}}\t{{.Repository}}' | sort -r'
alias dn='docker network ls'
alias dv='docker volume ls'
alias dc="docker-compose"
# KUBERNETES
alias k='kubectl'
alias ktx='kubectx'
alias kx='ktx -'
alias kns='kubens'
alias kap='k apply -f'
alias kdif="KUBECTL_EXTERNAL_DIFF='colordiff -N -u' kubectl diff -f"
alias kall='k get -A'
alias kgc='k get pod -o="custom-columns=NAME:.metadata.name,INIT-CONTAINERS:.spec.initContainers[*].name,CONTAINERS:.spec.containers[*].name"'
alias kgci='k get pod --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | tr -s \'[[:space:]]\' \'\n\' | sort | uniq -c'
alias dp='describepod'
alias tp='tailpod'
alias ep='execpod'
alias kpf='k port-forward'
alias kvs='k view-secret'
alias rbac='rbac-lookup'
alias kbox='k run kbox --image=jcortejoso/wscat -i --tty --attach --rm'
alias am='amtool'
alias aml='amtool alert'
alias ams='amtool silence'
alias kgno='k get no -o custom-columns=Name:".metadata.name",Kubelet:.status.nodeInfo.kubeletVersion,Status:.status.conditions[-1].reason,Date:".metadata.creationTimestamp",InstType:".metadata.labels.beta\.kubernetes\.io/instance-type,Cpu Cores:.status.capacity.cpu,Ram:.status.capacity.memory,Internal-IP:".status.addresses[0].address", External-IP:".status.addresses[1].address",Taints:.spec.taints" --sort-by=.metadata.creationTimestamp'
alias kgnog='k get no -o custom-columns=Name:".metadata.name",Kubelet:.status.nodeInfo.kubeletVersion,Status:.status.conditions[-1].reason,Date:".metadata.creationTimestamp",InstType:".metadata.labels.beta\.kubernetes\.io/instance-type,Cpu Cores:.status.capacity.cpu,Ram:.status.capacity.memory,Internal-IP:".status.addresses[0].address", External-IP:".status.addresses[1].address",Taints:.spec.taints" --sort-by=.metadata.creationTimestamp | grep $1'
alias kgoom="kgp --output=jsonpath='{ range .items[*]}{.status.containerStatuses[*].name} {.status.containerStatuses[*].lastState.terminated.reason } {.status.containerStatuses[*].lastState.terminated.finishedAt}{\"\n\"}{end}' | grep OOMKilled"
# KUBERNETES - basic
alias kgp='k get po'
alias kgpo='k get po -owide'
alias kgs='k get svc'
alias kgi='k get ing'
alias kgd='k get deploy'
alias kgsts='k get sts'
alias kgds='k get ds'
alias kgsec='k get secret'
alias kgsm='k get servicemonitor'
alias kgpr='k get prometheusrule'
alias kgns='k get ns'
alias kgcm='k get cm'
alias kgsa='k get sa'
alias kghpa='k get hpa'
alias kgsc='k get sc'
alias kgev='k get ev'
alias kgcert='k get cert'
alias kgcrs='k get crs'
alias kgissuer='k get issuer'
alias kgorder='k get order'
alias kgchallenge='k get challenge'
alias kgpv='k get pv'
alias kgpvc='k get pvc'
alias kgn='k get no'
alias kgpdb='k get pdb'
alias kgep='k get ep'
alias kgj='k get job'
alias kgcj='k get cj'
alias kgmci='k get mci'
alias kgmcs='k get mcs'
alias kgprobe='k get probe'
alias kgcr='k get clusterrole'
alias kgcrb='k get clusterrolebinding'
# KUBERNETES - sort by creation time
alias kgp1='k get po --sort-by=.metadata.creationTimestamp'
alias kgpo1='k get po -owide --sort-by=.metadata.creationTimestamp'
alias kgs1='k get svc --sort-by=.metadata.creationTimestamp'
alias kgi1='k get ing --sort-by=.metadata.creationTimestamp'
alias kgd1='k get deploy --sort-by=.metadata.creationTimestamp'
alias kgsts1='k get sts --sort-by=.metadata.creationTimestamp'
alias kgds1='k get ds --sort-by=.metadata.creationTimestamp'
alias kgsec1='k get secret --sort-by=.metadata.creationTimestamp'
alias kgsm1='k get servicemonitor --sort-by=.metadata.creationTimestamp'
alias kgpr1='k get prometheusrule --sort-by=.metadata.creationTimestamp'
alias kgns1='k get ns --sort-by=.metadata.creationTimestamp'
alias kgcm1='k get cm --sort-by=.metadata.creationTimestamp'
alias kgsa1='k get sa --sort-by=.metadata.creationTimestamp'
alias kghpa1='k get hpa --sort-by=.metadata.creationTimestamp'
alias kgsc1='k get sc --sort-by=.metadata.creationTimestamp'
alias kgev1='k get ev --sort-by=.metadata.creationTimestamp'
alias kgcert1='k get cert --sort-by=.metadata.creationTimestamp'
alias kgcrs1='k get crs --sort-by=.metadata.creationTimestamp'
alias kgissuer1='k get issuer --sort-by=.metadata.creationTimestamp'
alias kgorder1='k get order --sort-by=.metadata.creationTimestamp'
alias kgchallenge1='k get challenge --sort-by=.metadata.creationTimestamp'
alias kgpv1='k get pv --sort-by=.metadata.creationTimestamp'
alias kgpvc1='k get pvc --sort-by=.metadata.creationTimestamp'
alias kgn1='k get no --sort-by=.metadata.creationTimestamp'
alias kgpdb1='k get pdb --sort-by=.metadata.creationTimestamp'
alias kgep1='k get ep --sort-by=.metadata.creationTimestamp'
alias kgj1='k get job --sort-by=.metadata.creationTimestamp'
alias kgcj1='k get cj --sort-by=.metadata.creationTimestamp'
alias kgmci1='k get mci --sort-by=.metadata.creationTimestamp'
alias kgmcs1='k get mcs --sort-by=.metadata.creationTimestamp'
alias kgprobe1='k get probe --sort-by=.metadata.creationTimestamp'
alias kgcr1='k get clusterrole --sort-by=.metadata.creationTimestamp'
alias kgcrb1='k get clusterrolebinding --sort-by=.metadata.creationTimestamp'
# KUBERNETES - use neat plugin
alias kgp2='k neat get po'
alias kgpo2='k neat get po -owide'
alias kgs2='k neat get svc'
alias kgi2='k neat get ing'
alias kgd2='k neat get deploy'
alias kgsts2='k neat get sts'
alias kgds2='k neat get ds'
alias kgsec2='k neat get secret'
alias kgsm2='k neat get servicemonitor'
alias kgpr2='k neat get prometheusrule'
alias kgns2='k neat get ns'
alias kgcm2='k neat get cm'
alias kgsa2='k neat get sa'
alias kghpa2='k neat get hpa'
alias kgsc2='k neat get sc'
alias kgev2='k neat get ev'
alias kgcert2='k neat get cert'
alias kgcrs2='k neat get crs'
alias kgissuer2='k neat get issuer'
alias kgorder2='k neat get order'
alias kgchallenge2='k neat get challenge'
alias kgpv2='k neat get pv'
alias kgpvc2='k neat get pvc'
alias kgpdb2='k neat get pdb'
alias kgep2='k neat get ep'
alias kgj2='k neat get job'
alias kgcj2='k neat get cj'
alias kgmci2='k neat get mci'
alias kgmcs2='k neat get mcs'
alias kgprobe2='k neat get probe'
alias kgcr2='k neat get clusterrole'
alias kgcrb2='k neat get clusterrolebinding'
# KUBERNETES - grep specific resource
alias kgpg='kgp|grep $1'
alias kgpog='kgp -owide|grep $1'
alias kgsg='kgs|grep $1'
alias kgig='kgi|grep $1'
alias kgdg='kgd|grep $1'
alias kgstsg='kgsts|grep $1'
alias kgdsg='kgds|grep $1'
alias kgsecg='kgsec|grep $1'
alias kgsmg='kgsm|grep $1'
alias kgprg='kgpr|grep $1'
alias kgnsg='kgsn|grep $1'
alias kgcmg='kgcm|grep $1'
alias kgsag='kgsa|grep $1'
alias kghpag='kghpa|grep $1'
alias kgscg='kgsc|grep $1'
alias kgevg='kgsev|grep $1'
alias kgcertg='kgcert|grep $1'
alias kgcrsg='kgcrs|grep $1'
alias kgissuerg='kgissuer|grep $1'
alias kgorderg='k get order|grep $1'
alias kgchallengeg='k get challenge|grep $1'
alias kgpvg='kgpv|grep $1'
alias kgpvcg='kgpvc|grep $1'
alias kgng='kgn|grep $1'
alias kgpdbg='kgpdb|grep $1'
alias kgepg='k get ep|grep $1'
alias kgjg='k get job|grep $1'
alias kgcjg='k get cj|grep $1'
alias kgmcig='k get mci|grep $1'
alias kgmcsg='k get mcs|grep $1'
alias kgprobeg='k get probe|grep $1'
alias kgcrg='kgrc|grep $1'
alias kgcrbg='kgcrb|grep $1'
# KUBERNETES - describe
alias kdp='k describe po'
alias kds='k describe svc'
alias kdi='k describe ing'
alias kdd='k describe deploy'
alias kdsts='k describe sts'
alias kdds='k describe ds'
alias kdsec='k describe secret'
alias kdsm='k describe servicemonitor'
alias kdpr='k describe prometheusrule'
alias kdns='k describe ns'
alias kdcm='k describe cm'
alias kdsa='k describe sa'
alias kdhpa='k describe hpa'
alias kdsc='k describe sc'
alias kdev='k describe ev'
alias kdcert='k describe cert'
alias kdcrs='k describe crs'
alias kdissuer='k describe issuer'
alias kdorder='k describe order'
alias kdchallenge='k describe challenge'
alias kdpv='k describe pv'
alias kdpvc='k describe pvc'
alias kdn='k describe no'
alias kdpdb='k describe pdb'
alias kdep='k describe ep'
alias kdj='k describe job'
alias kdcj='k describe cj'
alias kdmci='k describe mci'
alias kdmcs='k describe mcs'
alias kdprobe='k describe probe'
alias kdcr='k describe clusterrole'
alias kdcrb='k describe clusterrolebinding'
# KUBERNETES - resources
alias ktp='k top pod'
alias ktpg='k top pod | grep $1'
alias ktp1='k top pod | sort --key 2 --numeric'
alias ktp2='k top pod | sort --key 3 --numeric'
alias ktpall='k top pod -A | sort --key 4 --numeric'
alias ktpallg='k top pod -A | grep $1'
alias ktpc='k top pod --containers'
alias ktpcg='k top pod --containers | grep $1'
alias ktn='k top no'
alias ktng='k top no | grep $1'
alias ktn1='k top no | sort --key 3 --numeric'
alias ktn2='k top no | sort --key 5 --numeric'
# ---------------------------------------------------------
alias kcn='k resource-capacity -u'
alias kcng='k resource-capacity -u | grep $1'
alias kcn1='k resource-capacity -u --sort cpu.util.percentage'
alias kcn2='k resource-capacity -u --sort mem.util.percentage'
alias kcp='k resource-capacity -p -u'
alias kcpg='k resource-capacity -p -u | grep $1'
alias kcp1='k resource-capacity -p -u --sort cpu.util.percentage'
alias kcp2='k resource-capacity -p -u --sort mem.util.percentage'
alias kcc='k resource-capacity -c -u'
alias kccg='k resource-capacity -c -u | grep $1'
alias kcc1='k resource-capacity -c -u --sort cpu.util.percentage'
alias kcc2='k resource-capacity -c -u --sort mem.util.percentage'
function kdbg
kubectl debug -it $argv[1] --image nicolaka/netshoot -- /bin/bash
end
function ktpn --argument node_name
printf "%-60s %-30s %-30s\n" "Node" "CPU" "Memory"
for line in (kgp -A --field-selector=metadata.namespace!=kube-system,metadata.namespace!=gmp-system,metadata.namespace!=monitoring,spec.nodeName=$node_name -o=jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}')
set namespace (echo $line | cut -d ' ' -f 1)
set pod (echo $line | cut -d ' ' -f 2)
set usage (kubectl top pod $pod -n $namespace --no-headers)
set cpu (echo $usage | awk '{print $2}')
set mem (echo $usage | awk '{print $3}')
printf "%-60s %-30s %-30s\n" $pod $cpu $mem
end
end