For example if a kubernetes cronjob runs and saves a file to disk, will it save on one of the containers my application is running on or will it save on a separate cronjob pod and then be destroyed?
CodePudding user response:
kubernetes cron job spin up a new container for every run. if you want to save file and manage it across each run then use persistent volume.
CodePudding user response:
Kubernetes CronJob
or CJ
creates a Job
which in turn creates a Pod
with a container inside. Containers by nature are ephemeral in nature, meaning that any file/logs generated inside are tied to its life-cycle. As long as the container lives, those files/logs will live. They will disappear when a container terminates.
In short, each CronJob
will create it's own file. If you want to persistent them permanently, attach a PersistentVolume
(PV
) with the CronJob
.
CodePudding user response:
From the CronJob docs:
A CronJob creates Jobs on a repeating schedule.
From the Jobs docs:
A Job creates one or more Pods
In other words, without configuration of a shared volume, the resulting Pod will be completely isolated from the rest of the cluster, and therefore your file will be written to the internal filesystem of the Pod container and destroyed on termination.