Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Job with single Pod vs single Pod with restart policy OnFailure

What are the benefits of a Job with single Pod over just a single Pod with restart policy OnFailure to reliably execute once in kubernetes?

As discussed in Job being constanly recreated despite RestartPolicy: Never, in case of a Job a new Pod will be created endlessly in case container returned non-zero status. The same applies to a single OnFailure Pod, only this time no new pods are created which is even cleaner.

What are the cons and pros of either approach? Can Pod restart parameters, such as restart delay, or number of retry attempts can be controlled in either case?

like image 504
Ivan Balashov Avatar asked Oct 19 '22 13:10

Ivan Balashov


1 Answers

The difference is that if a Job doesn't complete because the node that its pod was on went offline for some reason, then a new pod will be created to run on a different node. If a single pod doesn't complete because its node became unavailable, it won't be rescheduled onto a different node.

like image 145
Alex Robinson Avatar answered Oct 21 '22 06:10

Alex Robinson