59 lines
2.1 KiB
YAML
59 lines
2.1 KiB
YAML
# templates/cronjob.yaml
|
|
apiVersion: batch/v1
|
|
kind: CronJob
|
|
metadata:
|
|
name: {{ .Release.Name }}-cronjob
|
|
spec:
|
|
schedule: "{{ .Values.schedule }}"
|
|
startingDeadlineSeconds: 200 # Deadline for starting the job
|
|
concurrencyPolicy: Forbid # Prevents concurrent runs
|
|
successfulJobsHistoryLimit: 3 # Keeps last successful job
|
|
failedJobsHistoryLimit: 3 # Keeps last failed job
|
|
jobTemplate:
|
|
spec:
|
|
activeDeadlineSeconds: 180 # Limits how long a job can be active
|
|
ttlSecondsAfterFinished: 100 # Cleans up finished jobs after 100 seconds
|
|
backoffLimit: 3 # Number of retries before considering the job failed
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: temperature-fetcher
|
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
|
command: ["/bin/bash", "-c"]
|
|
args:
|
|
- |
|
|
echo "Running temperature_fetcher.py" && \
|
|
pip install requests && \
|
|
echo "Fetching temperature" && \
|
|
python /scripts/temperature_fetcher.py && \
|
|
sleep 300
|
|
resources:
|
|
requests:
|
|
cpu: "100m"
|
|
memory: "128Mi"
|
|
limits:
|
|
cpu: "200m"
|
|
memory: "256Mi"
|
|
env:
|
|
- name: CITY
|
|
value: "{{ .Values.city }}"
|
|
- name: API_KEY
|
|
value: "{{ .Values.apiKey }}"
|
|
- name: MOUNT_PATH
|
|
value: "{{ .Values.mountPath }}"
|
|
volumeMounts:
|
|
- name: sqlite-data
|
|
mountPath: "{{ .Values.mountPath }}"
|
|
- name: script-volume
|
|
mountPath: /scripts
|
|
restartPolicy: Never
|
|
volumes:
|
|
- name: sqlite-data
|
|
hostPath:
|
|
path: "{{ .Values.hostPath }}"
|
|
type: Directory
|
|
- name: script-volume
|
|
configMap:
|
|
name: {{ .Release.Name }}-script
|
|
|