I have many one-shot dockers to generate an output file in my project, they are small but cost many resources, so k8s is the best choice. In this scenario, I start pods by kubectl run --restart=Never
without any replication controllers. As a result, the output file is not guaranteed, and I have to handle them by myself including:
To remove succeeded pods, there seems no "--rm" argument in k8s as in the docker, nor the methods to pass into docker command, so kubectl delete pods --all
should be the only choice. What's worse, all the pods status are Error
or ExitCode:0
, but fortunately, the output file generated successfully.
To restart failed pods, I really have no idea on that right now.
So, does it look silly, or is there any better solutions?
Thanks in advance!
remove failed/succeeded pods
The kubelet has built in garbage collecting and exited containers from nodes. In addition, there is a gc controller to clean the actual objects from etcd.
restart failed pods.
The way one does this is via replication controller. Sounds like you want restartPolicy=OnFailure?