I need to periodically execute a script on a pod (kubernetes). I thought of a CronJob with an image invoking a SSH+command on my pod.
What's the best practice? Any suggestions?
Thank you Nicola
CronJobs and Jobs will run in their own pods, so do not support what you intend to do. They're not geared towards running things in other pods, rather running some generic workload on their own pod.
There's another solution though. A pod can have multiple containers. This allows those containers to share the same IP as well as any volumes mount on them. What you could setup is another "cron" container inside your pods, and have that container be in charge of running whatever script you need on whatever schedule you have. It'll have access to the same filesystem so it'll work as intended.