Kubernetes kubectl 命令提示

Kubernetes kubectl About 937 words

PowerShell

将如下命令追加到$PROFILE中,且重新打开PowerShell

kubectl completion powershell | Out-String | Invoke-Expression

示例

echo 'kubectl completion powershell | Out-String | Invoke-Expression' >> $PROFILE

注意:$PROFILE的路径位于$HOME/WindowsPowerShell下,WindowsPowerShell默认不存在,需提前创建。

mkdir $HOME/WindowsPowerShell

Bash

Linux

echo 'source <(kubectl completion bash)' >>~/.bashrc

配置别名也生效

echo 'alias k=kubectl' >>~/.bashrc
echo 'complete -o default -F __start_kubectl k' >>~/.bashrc

macOS

echo 'source <(kubectl completion bash)' >>~/.bash_profile

配置别名也生效

echo 'alias k=kubectl' >>~/.bash_profile
echo 'complete -o default -F __start_kubectl k' >>~/.bash_profile

参考

https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-pwsh

https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-linux

https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-mac

Views: 1,202 · Posted: 2022-10-28

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh