不同执行结果管理pods的方法

Ways to manage pods in different executing result

我的项目中有很多一次性docker生成一个输出文件,它们很小但是很费资源,所以k8s是最好的选择。在这种情况下,我通过 kubectl run --restart=Never 启动 pods,没有任何复制控制器。结果,输出文件无法保证,我必须自己处理包括:

删除成功pods,k8s中似乎没有docker中的“--rm”参数,也没有传递给docker命令的方法,所以kubectl delete pods --all 应该是唯一的选择。更糟糕的是,所有的pods状态都是ErrorExitCode:0,还好输出文件生成成功

重新启动失败pods,我现在真的不知道。

所以,它看起来很傻,还是有更好的解决方案?

提前致谢!

remove failed/succeeded pods

kubelet 已内置 garbage collecting and exited containers from nodes. In addition, there is a gc controller to clean the actual objects from etcd

restart failed pods.

这样做的方法是通过复制控制器。听起来你想要 restartPolicy=OnFailure