当前位置:网站首页>总结了 800多个 Kubectl 别名,再也不怕记不住命令了!
总结了 800多个 Kubectl 别名,再也不怕记不住命令了!
2022-07-05 23:32:00 【进击云原生】
总结了 800多个 Kubectl 别名,再也不怕记不住命令了!
这个存储库包含脚本 gener_ aliases.py
可以生成数百个方便的 kubectl shell 别名,您不再需要拼写出每个命令和--flag
参数。
https://github.com/ahmetb/kubectl-aliases/blob/master/generate_aliases.py
通过命令/标志排列创建的 shell 别名示例如下:
alias ksysgdepwslowidel='kubectl --namespace=kube-system get deployment --watch --show-labels -o=wide -l'
示例
800 个别名,下面列出一部分:
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'
...
访问下面地址,查看所有别名:
https://github.com/ahmetb/kubectl-aliases/blob/master/.kubectl_aliases
安装
您可以直接下载 bash/zsh 的文件.kubectl_aliases
:
https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases
或者 fish 的文件.kubectl_aliases.fish
,并将其保存到$HOME
目录中。
https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases.fish
Bash/Zsh
将以下内容添加到您的.bashrc/.zshrc
文件中:
[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases
建议:如果想使用 GNU watch 命令而不是 kubectl [...] --watch,请这样运行:
[ -f ~/.kubectl_aliases ] && source \
<(cat ~/.kubectl_aliases | sed -r 's/(kubectl.*) --watch/watch \1/g')
在运行之前打印完整的命令:将其添加到您的.bashrc
或 .zshrc
文件中:
function kubectl() { echo "+ kubectl [email protected]">&2; command kubectl [email protected]; }
Fish
添加下面内容到你的~/.config/fish/config.fish
文件:
test -f ~/.kubectl_aliases.fish && source ~/.kubectl_aliases.fish
这实际上增加了更强大的 fish 缩写:
https://fishshell.com/docs/current/cmds/abbr.html
而不是别名,这样在执行前按空格显示完整的命令。
建议:如果想使用 GNU watch 命令而不是 kubectl [...] --watch,请这样运行:
test -f ~/.kubectl_aliases.fish && source \
(cat ~/.kubectl_aliases.fish | sed -r 's/(kubectl.*) --watch/watch \1/g' | psub)
语法解释
k
=kubectl
sys
=--namespace kube-system
commands: g
=get
d
=describe
rm
=delete
a
:apply -f
ak
:apply -k
k
:kustomize
ex
:exec -i -t
lo
:logs -f
resources: po
=pod,dep
=deployment
,ing
=ingress
,svc
=service
,cm
=configmap
,sec
=secret
,ns
=namespace
,no
=node
flags: output format: oyaml
,ojson
,owide
all
:--all
or--all-namespaces
depending on the commandsl
:--show-labels
w
=-w/--watch
value flags (should be at the end): n
=-n/--namespace
f
=-f/--filename
l
=-l/--selector
运行脚本
该脚本只有一个可选参数,即:将生成别名的 shell。如果不指定,则默认为bash
。例如:
# Generate aliases for bash/zsh
python generate_aliases.py > .kubectl_aliases
# Generate abbr for fish
python generate_aliases.py fish > .kubectl_aliases.fish
交流
请关注微信公众号【进击云原生】,扫码关注,了解更多咨询,更有免费资源供您学习
边栏推荐
- Neural structured learning 4 antagonistic learning for image classification
- Neural structured learning - Part 2: training with natural graphs
- Neural structured learning - Part 3: training with synthesized graphs
- Live tiktok shop 2022 latest gameplay card slot overseas live e-commerce new traffic
- The PostgreSQL column reference 'ID' is ambiguous - PostgreSQL column reference'id'is ambiguous
- Comparison between webgl and webgpu [3] - vertex buffer
- yate.conf
- TVS管和ESD管的技術指標和選型指南-嘉立創推薦
- Hcip course notes-16 VLAN, three-tier architecture, MPLS virtual private line configuration
- Use mapper: --- tkmapper
猜你喜欢
Brushless drive design -- on MOS drive circuit
MySQL delete uniqueness constraint unique
MySQL replace primary key delete primary key add primary key
Fiddler Everywhere 3.2.1 Crack
【LeetCode】5. Valid Palindrome·有效回文
芯源&立创EDA训练营——无刷电机驱动
Huawei simulator ENSP - hcip - MPLS experiment
GFS分布式文件系統
There are 14 God note taking methods. Just choose one move to improve your learning and work efficiency by 100 times!
rsync远程同步
随机推荐
帶外和帶內的區別
C# Linq Demo
yate. conf
【EF Core】EF Core与C# 数据类型映射关系
poj 2762 Going from u to v or from v to u? (infer whether it is a weak link diagram)
When to use useImperativeHandle, useLayoutEffect, and useDebugValue
20220703 周赛:知道秘密的人数-动规(题解)
11gR2 Database Services for &quot;Policy&quot; and &quot;Administrator&quot; Managed Databases (文件 I
Objective C message dispatch mechanism
Spreadjs 15.1 CN and spreadjs 15.1 en
Fiddler Everywhere 3.2.1 Crack
14 MySQL-视图
CIS benchmark tool Kube bench
Convert Chinese into pinyin
成为程序员的你,后悔了吗?
Technical specifications and model selection guidelines for TVs tubes and ESD tubes - recommended by jialichuang
Scala concurrent programming (II) akka
【LeetCode】5. Valid palindrome
GFS Distributed File System
The interface of grafana tool displays an error, incluxdb error