kubectl命令补全

1. 补全命令不生效

【问题】

每次打开终端都需执行 source <(kubectl completion bash) ,否则补全不生效

【解决】

将命令写入profile.d中

# cat > /etc/profile.d/k8s_source.sh << EOF
source <(kubectl completion bash)
EOF

之后打开新终端都可以正常补全。

2. -bash: _get_comp_words_by_ref: 未找到命令

【问题】

上文操作后,tab补全时报错如下:

-bash: _get_comp_words_by_ref: 未找到命令

【解决】

需要安装 bash-completion

# yum install bash-completion -y
# source /usr/share/bash-completion/bash_completion
# source <(kubectl completion bash)

在这里插入图片描述

posted on   运维开发玄德公  阅读(31)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~
< 2025年2月 >
26 27 28 29 30 31 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 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示