[Fix] DevContainer Completed and then CrashLoopBackOff

This commit is contained in:
DAI Mingchen
2024-10-28 20:39:17 +08:00
repo.diff.parent 6967ba9889
repo.diff.commit f10c5305ee

repo.diff.view_file

@@ -37,7 +37,9 @@ func AssignDevcontainerCreation2K8sOperator(ctx *context.Context, newDevContaine
* 配置 Kubernetes 主容器启动命令注意事项:
* 1. 确保 Image 中已安装 OpenSSH Server
* 2. 容器启动后必须拉起 OpenSSH 后台服务
* 3. 请勿使用 sleep infinity 或者 tail -f /dev/null 等无限等待命令,否则将造成大量僵尸(<defunct>)进程:
* 3. 请勿使用 sleep infinity 或者 tail -f /dev/null 等无限等待命令,
* 可以考虑无限循环 sleep 60s能够防止 k8s 中容器先变成 Completed 然后变为 CrashLoopBackOff
* 也可以防止造成大量僵尸(<defunct>)进程:
* $ ps aux | grep "<defunct>" # 列举僵尸进程
* USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
* pollina+ 2336 0.0 0.0 0 0 ? Z 17:22 0:00 [sshd] <defunct>
@@ -54,7 +56,7 @@ func AssignDevcontainerCreation2K8sOperator(ctx *context.Context, newDevContaine
CommandList: []string{
"/bin/bash",
"-c",
"service ssh restart",
"service ssh start && while true; do sleep 60; done",
},
ContainerPort: 22,
ServicePort: 22,