I have a cronjob being deployed to two different clusters. Each cluster is a different region. Having these jobs running on two different clusters is to help insure the cronjob will run if one of the regions goes down.
I want the two deployments to be able to check if the deployment on the other cluster is running. If it is, the cronjob should not run. I do have concurrencyPolicy
set to false, but that only matters for the cluster the cronjob is running on.
Is this something that is even possible?
Here is a basic idea of my Helm chart
apiVersion: batch/v1
kind: CronJob
metadata:
name:
namespace:
labels:
app.kubernetes.io/component: cronjob
app.kubernetes.io/instance:
app.kubernetes.io/managed-by: helm
app.kubernetes.io/name:
app.kubernetes.io/part-of:
spec:
schedule:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 0
successfulJobsHistoryLimit: 0
jobTemplate:
spec:
activeDeadlineSeconds: 240
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
app.kubernetes.io/component: cronjob
app.kubernetes.io/instance:
app.kubernetes.io/managed-by: helm
app.kubernetes.io/name:
app.kubernetes.io/part-of:
spec:
imagePullSecrets:
- name:
serviceAccountName:
restartPolicy: OnFailure
containers:
- name:
image:
command: ["dumb-init", "node", "./main.js"]
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: "256m"
memory: "1G"
env:
- name:
value:
envFrom:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: Criticality
operator: In
values:
- Important