能否避免 pod 在 kubectl attach 后重启?

Can you avoid the pod to be restarted after kubectl attach?

我有一个 ubuntu 图像用于调试。 我做了 kubectl attach my-app -c my-app -it,然后做了很多 apt-get install 和我需要的其他配置。

问题是当我退出时 ctrl+c pod 似乎重新启动了,我失去了我所做的一切
有没有像--restart=never这样的方法来避免重新创建容器

运行 另一个 shell 会话 kubectl exec my-app -c my-app -it -- bash 来准备您的容器。或者,如果您的 pod 规范将以下设置为 true:

stdin: true 
tty: true 

您使用转义序列 Ctrl+P 后跟 Ctrl+Q 在 kubectl attach -it 之后从容器分离到容器。