Kubernetes CronJob
Wrap the container command so every run reports.
Wrap the container's command so every run reports. The simplest form needs only curl in the image:
apiVersion: batch/v1
kind: CronJob
metadata:
name: cleanup
spec:
schedule: "*/30 * * * *"
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
containers:
- name: cleanup
image: ghcr.io/example/cleanup:latest
env:
- name: VIVERE_PING_URL
valueFrom:
secretKeyRef: { name: vivere, key: ping-url }
command: ["/bin/sh", "-c"]
args:
- |
curl -fsS -m 10 "$VIVERE_PING_URL/start" || true
/app/cleanup; code=$?
curl -fsS -m 10 "$VIVERE_PING_URL/$code" || true
exit $code
With the vivere binary copied into the image (COPY --from=… /vivere /usr/local/bin/), it becomes command: ["vivere", "run", "--", "/app/cleanup"] and the output is captured too.
Put the ping URL in a Secret rather than the manifest; it is the only credential a monitor has.