Skip to content

Commit 34ff049

Browse files
committed
k8s: add weekly refresh cronjob for cacao-demo and ca-wolves
Recreates both deployments every Sunday at 03:00 UTC to pull fresh app code from the source repos (deployments use git-clone init containers, so a restart picks up upstream changes). Resource requests=limits to satisfy the schmidtdse namespace's gatekeeper ratio policy. Uses alpine/k8s image since bitnami/kubectl was deprecated and rancher/kubectl is FROM scratch (no shell).
1 parent c004b39 commit 34ff049

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

‎k8s/refresh-cronjob.yaml‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: schmidtdse-refresh
5+
namespace: schmidtdse
6+
---
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: Role
9+
metadata:
10+
name: schmidtdse-refresh
11+
namespace: schmidtdse
12+
rules:
13+
- apiGroups: ["apps"]
14+
resources: ["deployments"]
15+
verbs: ["get", "list", "create", "update", "patch", "delete"]
16+
---
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: RoleBinding
19+
metadata:
20+
name: schmidtdse-refresh
21+
namespace: schmidtdse
22+
subjects:
23+
- kind: ServiceAccount
24+
name: schmidtdse-refresh
25+
namespace: schmidtdse
26+
roleRef:
27+
kind: Role
28+
name: schmidtdse-refresh
29+
apiGroup: rbac.authorization.k8s.io
30+
---
31+
apiVersion: batch/v1
32+
kind: CronJob
33+
metadata:
34+
name: schmidtdse-refresh
35+
namespace: schmidtdse
36+
spec:
37+
# Weekly, Sundays at 03:00 UTC
38+
schedule: "0 3 * * 0"
39+
concurrencyPolicy: Forbid
40+
successfulJobsHistoryLimit: 3
41+
failedJobsHistoryLimit: 3
42+
jobTemplate:
43+
spec:
44+
backoffLimit: 2
45+
template:
46+
spec:
47+
serviceAccountName: schmidtdse-refresh
48+
restartPolicy: OnFailure
49+
initContainers:
50+
- name: git-clone-cacao-demo
51+
image: alpine/git:2.52.0
52+
command:
53+
- sh
54+
- -c
55+
- git clone --depth 1 https://github.com/SchmidtDSE/cacao-demo.git /workspace/cacao-demo
56+
resources:
57+
requests:
58+
cpu: "100m"
59+
memory: "128Mi"
60+
limits:
61+
cpu: "100m"
62+
memory: "128Mi"
63+
volumeMounts:
64+
- name: workspace
65+
mountPath: /workspace
66+
- name: git-clone-ca-wolves
67+
image: alpine/git:2.52.0
68+
command:
69+
- sh
70+
- -c
71+
- git clone --depth 1 https://github.com/SchmidtDSE/ca-wolves.git /workspace/ca-wolves
72+
resources:
73+
requests:
74+
cpu: "100m"
75+
memory: "128Mi"
76+
limits:
77+
cpu: "100m"
78+
memory: "128Mi"
79+
volumeMounts:
80+
- name: workspace
81+
mountPath: /workspace
82+
containers:
83+
- name: kubectl
84+
image: alpine/k8s:1.30.14
85+
workingDir: /workspace
86+
command:
87+
- sh
88+
- -c
89+
- |
90+
set -e
91+
for repo in cacao-demo ca-wolves; do
92+
kubectl delete -f "${repo}/k8s/deployment.yaml" --ignore-not-found
93+
kubectl apply -f "${repo}/k8s/deployment.yaml"
94+
done
95+
resources:
96+
requests:
97+
cpu: "200m"
98+
memory: "256Mi"
99+
limits:
100+
cpu: "200m"
101+
memory: "256Mi"
102+
volumeMounts:
103+
- name: workspace
104+
mountPath: /workspace
105+
volumes:
106+
- name: workspace
107+
emptyDir: {}

0 commit comments

Comments
 (0)