What I am trying to do:
The app that runs in the Pod does some refreshing of its data files on start. I need to restart the container each time I want to refresh the data. (A refresh can take a few minutes, so I have a Probe checking for readiness.)
What I think is a solution:
I will run a scheduled job to do a rolling-update kind of deploy, which will take the old Pods out, one at a time and replace them, without downtime.
Where I'm stuck:
How do I trigger a deploy, if I haven't changed anything??
Also, I need to be able to do this from the scheduled job, obviously, so no manual editing..
Any other ways of doing this?
As of kubectl 1.15, you can run:
What this does internally, is patch the deployment with a
kubectl.kubernetes.io/restartedAt
annotation so the scheduler performs a rollout according to the deployment update strategy.For previous versions of Kubernetes, you can simulate a similar thing:
And even replace all in a single namespace:
According to documentation:
You can just use
kubectl patch
to update i.e. a label inside.spec.template
.