-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk8s-cronjob.yaml
More file actions
44 lines (43 loc) · 1.58 KB
/
Copy pathk8s-cronjob.yaml
File metadata and controls
44 lines (43 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Carbon-aware Kubernetes CronJob
#
# Runs a deferrable batch job (here: a placeholder) only when the grid is clean.
# An initContainer runs `carbon-aware wait-for-green`; if it exits non-zero
# (no green window within the deadline) the Pod fails and the next schedule
# tries again. This is where carbon-aware scheduling actually moves the needle:
# large, deferrable batch/ML/ETL workloads, not CI.
#
# Build/push the image from the repo's Dockerfile first:
# docker build -t your-registry/carbon-aware:latest .
# docker push your-registry/carbon-aware:latest
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-batch-carbon-aware
spec:
# Fire often; the gate decides whether work actually runs
schedule: "0 * * * *"
concurrencyPolicy: Forbid
jobTemplate:
spec:
# Give the job the whole window to find a green hour
activeDeadlineSeconds: 21600 # 6h
template:
spec:
restartPolicy: Never
initContainers:
- name: wait-for-green
image: your-registry/carbon-aware:latest
args:
- wait-for-green
- --zones=auto:green
- --max-carbon=200
- --max-wait=6h
- --poll=15m
# Optional provider tokens for broader coverage:
# env:
# - name: ENTSOE_TOKEN
# valueFrom: { secretKeyRef: { name: carbon, key: entsoe } }
containers:
- name: batch
image: busybox
command: ["sh", "-c", "echo 'Running batch work on clean energy'; sleep 5"]