Does Kubernetes reuse containers from previous cron jobs?

2/2/2021

Should I worry about leaving my container dirty? For example if I create files every time it's run, should I delete these files at the end of the job?

-- throwaway919
kubernetes

1 Answer

2/2/2021

Every file you create will be deleted when the job finishes unless you mount a persistent volume, that way you can share data between subsequent runs of the same job.

So, you shouldn't worry to delete the files you created unless they are bigger than ~40GB


Additional resources:

On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers. One problem is the loss of files when a container crashes. The kubelet restarts the container but with a clean state. (this applies to newly created Jobs too).

A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate.

-- paltaa
Source: StackOverflow