Randomize CronJob or any other time based schedules is a crucial topic.
Example:
local scope = "…" // Something that defines the scope of the schedule
local minute = std.foldl(function(x, y) x + y, std.encodeUTF8(std.md5(scope)), 0) % 60;
local job = kube.CronJob(name) {
spec+: {
schedule: '%d * * * *' % minute,
…
}
Using a hash function makes the result deterministic. For that reason, the scope becomes important to ensure distribution of values.
Suggestions:
For things running on clusters but act against a common system, use the cluster name. This will ensure, that all those jobs are executed at a different time.
For things running on the same cluster but should be spread over time, use something like the namespace and or job name the job is running in. The same job will run at the same time on every cluster but different jobs on a cluster will run a different times
Mixing in the the clusters name with namespace and or job names will ensure that different jobs run at different times both on the same cluster as well as the whole fleet of clusters.
Randomize CronJob or any other time based schedules is a crucial topic.
Example:
Using a hash function makes the result deterministic. For that reason, the scope becomes important to ensure distribution of values.
Suggestions:
See also https://github.com/appuio/component-openshift4-authentication/commit/bfbff9dfb1252bf7753a60da3581bf29a727b619