安装 krew
下载 krew 文件
powershell
curl -fsSL https://github.com/kubernetes-sigs/krew/releases/download/v0.5.0/krew-linux_amd64.tar.gz | tar xzf -
安装
powershell
./krew-linux_amd64 install krew

将 krew 添加到 PATH
powershell
echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc
重新加载配置
powershell
source ~/.bashrc
检查 krew 是否安装成功
powershell
kubectl krew version

安装 node-shell 插件
powershell
kubectl krew install node-shell

使用 node-shell (拥有完整的 root 权限)
powershell
kubectl node-shell <node-name>
kubectl node-shell k8s-node01

替代方案(如果不想安装 krew 权限小)
powershell
kubectl debug node/<node-name> -it --image=ubuntu:22.04
kubectl debug node/k8s-node01 -it --image=ubuntu:22.04
