2

I'm having a flask app that fetches data from external source only at application startup. I need to refresh app data, and the easiest way (without changing app logic) would be to daily restart deployment (scale pod to zero and up again).

Is this possible to achieve this in deployment configuration (DeploymentConfig)? OpenShift version is v3.11.104.

diman82
  • 702
  • 8
  • 11
  • You could schedule a [CronJob](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/), and have it started a container that deletes your your application pod (causing it to be re-created by your deployment). That would probably be created outside of your `DeploymentConfig`, which if it's anything like a `Deployment` only manages pods. – larsks Jan 11 '21 at 21:40
  • @larsks What do you mean by: "have it started a container that deletes your your application pod"? Having a Cronjob with some 'oc delete ' command? Even if this actually works, I still need to somehow dynamically fetch a (suppose you kill a pod, and OpenShift recreates a new one from DeploymentConfig - you will need to know the new pod id for next delete, right). – diman82 Jan 12 '21 at 20:57

1 Answers1

0

Seems to be solvable with running an app using OpenShift Cronjob, configuring the Cronjob to be run every day, and setting ConcurrencyPolicy param to Replace.

diman82
  • 702
  • 8
  • 11