当前位置:网站首页>After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
After summarizing more than 800 kubectl aliases, I'm no longer afraid that I can't remember commands!
2022-07-05 23:51:00 【Attack cloud primordial】
Sum up 800 Multiple Kubectl Alias , I'm no longer afraid that I can't remember orders !
This repository contains scripts gener_ aliases.py It can generate hundreds of convenient kubectl shell Alias , You no longer need to spell out every command and --flag Parameters .
https://github.com/ahmetb/kubectl-aliases/blob/master/generate_aliases.py
Through the command / Flag arrangement created shell Examples of aliases are as follows :
alias ksysgdepwslowidel='kubectl --namespace=kube-system get deployment --watch --show-labels -o=wide -l'
Example
800 An alias , Some are listed below :
alias k='kubectl'
alias kg='kubectl get'
alias kgpo='kubectl get pod'
alias ksysgpo='kubectl --namespace=kube-system get pod'
alias krm='kubectl delete'
alias krmf='kubectl delete -f'
alias krming='kubectl delete ingress'
alias krmingl='kubectl delete ingress -l'
alias krmingall='kubectl delete ingress --all-namespaces'
alias kgsvcoyaml='kubectl get service -o=yaml'
alias kgsvcwn='kubectl get service --watch --namespace'
alias kgsvcslwn='kubectl get service --show-labels --watch --namespace'
alias kgwf='kubectl get --watch -f'
...
Visit the address below , See all aliases :
https://github.com/ahmetb/kubectl-aliases/blob/master/.kubectl_aliases
install
You can download bash/zsh The file of .kubectl_aliases:
https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases
perhaps fish The file of .kubectl_aliases.fish, And save it to $HOME Directory .
https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases.fish
Bash/Zsh
Add the following to your .bashrc/.zshrc In file :
[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases
Suggest : If you want to use GNU watch Order, not kubectl [...] --watch, Please run like this :
[ -f ~/.kubectl_aliases ] && source \
<(cat ~/.kubectl_aliases | sed -r 's/(kubectl.*) --watch/watch \1/g')
Print the complete command before running : Add it to your .bashrc or .zshrc In file :
function kubectl() { echo "+ kubectl [email protected]">&2; command kubectl [email protected]; }
Fish
Add the following to your ~/.config/fish/config.fish file :
test -f ~/.kubectl_aliases.fish && source ~/.kubectl_aliases.fish
This actually adds more powerful fish abbreviation :
https://fishshell.com/docs/current/cmds/abbr.html
Not an alias , In this way, press the space to display the complete command before execution .
Suggest : If you want to use GNU watch Order, not kubectl [...] --watch, Please run like this :
test -f ~/.kubectl_aliases.fish && source \
(cat ~/.kubectl_aliases.fish | sed -r 's/(kubectl.*) --watch/watch \1/g' | psub)
Grammar explanation
k=kubectlsys=--namespace kube-system
commands: g=getd=describerm=deletea:apply -fak:apply -kk:kustomizeex:exec -i -tlo:logs -f
resources: po=pod,dep=deployment,ing=ingress,svc=service,cm=configmap,sec=secret,ns=namespace,no=node
flags: output format: oyaml,ojson,owideall:--allor--all-namespacesdepending on the commandsl:--show-labelsw=-w/--watch
value flags (should be at the end): n=-n/--namespacef=-f/--filenamel=-l/--selector
Run script
The script has only one optional parameter , namely : Alias will be generated shell. If you don't specify , The default is bash. for example :
# Generate aliases for bash/zsh
python generate_aliases.py > .kubectl_aliases
# Generate abbr for fish
python generate_aliases.py fish > .kubectl_aliases.fish
communication
Please follow the WeChat public account 【 Attack the cloud 】, Sweep yards attention , Learn more about consulting , There are more free resources for you to learn

边栏推荐
- Make a short video clip number of we media film and television. Where can I download the material?
- Bao Yan notes II software engineering and calculation volume II (Chapter 13-16)
- Do you regret becoming a programmer?
- 激光slam学习记录
- Golang code checking tool
- CIS benchmark tool Kube bench
- Latex multiple linebreaks
- 21. PWM application programming
- Effet Doppler (déplacement de fréquence Doppler)
- CAS and synchronized knowledge
猜你喜欢

激光slam学习记录

C reflection and type

GFS分布式文件系统

Senparc.Weixin.Sample.MP源码剖析
![[day39 literature extensive reading] a Bayesian perspective on magnetic estimation](/img/9c/438ef820a9f703c21f708bfc1dbbc4.jpg)
[day39 literature extensive reading] a Bayesian perspective on magnetic estimation

Go language introduction detailed tutorial (I): go language in the era

Open source CRM customer relationship system management system source code, free sharing

MySQL replace primary key delete primary key add primary key

Breadth first search open turntable lock

同事悄悄告诉我,飞书通知还能这样玩
随机推荐
rsync远程同步
ts类型声明declare
传输层协议------UDP协议
Cwaitabletimer timer, used to create timer object access
15 MySQL-存储过程与函数
Open source CRM customer relationship system management system source code, free sharing
Use CAS instead of synchronized
Switching power supply buck circuit CCM and DCM working mode
QT a simple word document editor
XML配置文件(DTD详细讲解)
11gR2 Database Services for &quot; Policy&quot; and &quot; Administrator&quot; Managed databases (file I
STM32__06—单通道ADC
14 MySQL-视图
保研笔记四 软件工程与计算卷二(8-12章)
[gym 102832h] [template] combination lock (bipartite game)
GFS distributed file system
Objective C message dispatch mechanism
The use of El cascader and the solution of error reporting
Latex multiple linebreaks
XML configuration file (DTD detailed explanation)