当前位置:网站首页>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

边栏推荐
- ts类型声明declare
- 动态规划 之 打家劫舍
- CloudCompare&PCL 点云随机添加噪声
- My colleagues quietly told me that flying Book notification can still play like this
- 2022.6.20-6.26 AI industry weekly (issue 103): new little life
- XML配置文件(DTD详细讲解)
- 【LeetCode】5. Valid Palindrome·有效回文
- Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
- 单商户V4.4,初心未变,实力依旧!
- Difference between out of band and in band
猜你喜欢

Hcip course notes-16 VLAN, three-tier architecture, MPLS virtual private line configuration

用列錶初始化你的vector&&initializer_list簡介

GFS分布式文件系統

20220703 周赛:知道秘密的人数-动规(题解)

Comparison of parameters between TVs tube and zener diode

保研笔记二 软件工程与计算卷二(13-16章)

Online yaml to CSV tool

C reflection and type

rsync远程同步

如何获取localStorage中存储的所有值
随机推荐
妙才周刊 - 8
【GYM 102832H】【模板】Combination Lock(二分图博弈)
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
98. Verify the binary search tree ●●
2022.6.20-6.26 AI industry weekly (issue 103): new little life
Fiddler Everywhere 3.2.1 Crack
[Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
How to rotate the synchronized / refreshed icon (EL icon refresh)
[day39 literature extensive reading] a Bayesian perspective on magnetic estimation
idea 连接mysql ,直接贴配置文件的url 比较方便
My colleagues quietly told me that flying Book notification can still play like this
CIS benchmark tool Kube bench
Effet Doppler (déplacement de fréquence Doppler)
Naoqi robot summary 26
做自媒体影视短视频剪辑号,在哪儿下载素材?
如何获取localStorage中存储的所有值
Redis高可用——主从复制、哨兵模式、集群
VBA fast switching sheet
保研笔记一 软件工程与计算卷二(1-7章)
Rasa 3.x 学习系列-Rasa 3.2.1 新版本发布