如何启用 kubernetes 命令自动完成

Luk*_*ski 3 kubernetes

我厌倦了手写所有kubectlkubeadm命令。有没有办法在这些命令上启用自动完成功能?

Luk*_*ski 9

Bash 解决方案

# Execute these commands
$ echo "source <(kubectl completion bash)" >> ~/.bashrc
$ echo "source <(kubeadm completion bash)" >> ~/.bashrc

# Reload bash without logging out
$ source ~/.bashrc 
Run Code Online (Sandbox Code Playgroud)