@@ -493,15 +493,43 @@ kubectl delete pod myapp myapp-debug
493
493
<!--
494
494
## Debugging via a shell on the node {#node-shell-session}
495
495
496
- If none of these approaches work, you can find the host machine that the pod is
497
- running on and SSH into that host, but this should generally not be necessary
498
- given tools in the Kubernetes API. Therefore, if you find yourself needing to
499
- ssh into a machine, please file a feature request on GitHub describing your use
500
- case and why these tools are insufficient.
496
+ If none of these approaches work, you can find the Node on which the Pod is
497
+ running and create a privileged Pod running in the host namespaces. To create
498
+ an interactive shell on a node using `kubectl debug`, run:
501
499
-->
502
- ## 在节点上通过 shell 来调试 {#node-shell-session}
500
+ ## 在节点上通过 shell 来进行调试 {#node-shell-session}
503
501
504
- 如果这些方法都不起作用,你可以找到运行 Pod 的主机并通过 SSH 进入该主机,
505
- 但是如果使用 Kubernetes API 中的工具,则通常不需要这样做。
506
- 因此,如果你发现自己需要使用 ssh 进入主机,请在GitHub 上提交功能请求,
507
- 以描述你的用例以及这些工具不足的原因。
502
+ 如果这些方法都不起作用,你可以找到运行 Pod 的节点,然后在节点上部署一个运行在宿主名字空间的特权 Pod。
503
+
504
+ 你可以通过` kubectl debug ` 在节点上创建一个交互式 shell:
505
+
506
+ ``` shell
507
+ kubectl debug node/mynode -it --image=ubuntu
508
+ ```
509
+
510
+ ```
511
+ Creating debugging pod node-debugger-mynode-pdx84 with container debugger on node mynode.
512
+ If you don't see a command prompt, try pressing enter.
513
+ root@ek8s:/#
514
+ ```
515
+
516
+ <!--
517
+ When creating a debugging session on a node, keep in mind that:
518
+
519
+ * `kubectl debug` automatically generates the name of the new Pod based on
520
+ the name of the Node.
521
+ * The container runs in the host IPC, Network, and PID namespaces.
522
+ * The root filesystem of the Node will be mounted at `/host`.
523
+
524
+ Don't forget to clean up the debugging Pod when you're finished with it:
525
+ -->
526
+ 当在节点上创建调试会话,注意以下要点:
527
+ * ` kubectl debug ` 基于节点的名字自动生成新的 Pod 的名字。
528
+ * 新的调试容器运行在宿主命名空间里(IPC, 网络 还有PID命名空间)。
529
+ * 节点的根文件系统会被挂载在 ` /host ` 。
530
+
531
+ 当你完成节点调试时,不要忘记清理调试 Pod:
532
+
533
+ ``` shell
534
+ kubectl delete pod node-debugger-mynode-pdx84
535
+ ```
0 commit comments