# kubectl krew install node-shell Updated the local copy of plugin index. Installing plugin: node-shell Installed plugin: node-shell \ | Use this plugin: | kubectl node-shell | Documentation: | https://github.com/kvaps/kubectl-node-shell | Caveats: | \ | | You need to be allowed to start privileged pods in the cluster | / / WARNING: You installed plugin "node-shell" from the krew-index plugin repository. These plugins are not audited for security by the Krew maintainers. Run them at your own risk.
2. 进入节点的shell
2.1. 登录node
创建一个临时的特权容器,登录容器即登录node shell。
1
kubectl node-shell <node-name>
示例:
1 2 3 4 5 6 7 8
# kubectl node-shell node1 spawning "nsenter-9yqytp" on "node1" If you don't see a command prompt, try pressing enter. groups: cannot find name for group ID 11 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. root@node1:/#
2.2. 退出node
退出容器,容器会被自动删除。
1 2 3 4
# exit logout pod default/nsenter-9yqytp terminated (Error) pod "nsenter-9yqytp" deleted