Scheduled jobs
Deploy an app with a Schedule such as 0 3 * * * (in the console, the Schedule (cron) field of the Deploy app form) (or @hourly, @daily, @weekly, …) and, optionally, a time_zone. A scheduled app has no port: it runs as a Kubernetes CronJob instead of a Deployment. The time zone can be set through the API only.
curl -fsS -X POST "$KUBEN_URL/api/v1/projects/shop/environments/production/apps" \ -H "Authorization: Bearer $KUBEN_TOKEN" -H 'Content-Type: application/json' \ -d '{ "name": "nightly-report", "image": "ghcr.io/acme/reports:1.8.0", "command": ["report", "--yesterday"], "schedule": "0 3 * * *", "time_zone": "Europe/Berlin", "env": [{ "name": "DATABASE_URL", "secret": { "name": "db-credentials", "key": "url" } }] }'Behaviour
Section titled “Behaviour”- No overlaps. A scheduled run never starts while the previous one is still running. Run now starts a run even if one is.
- Limits. A failed run is retried once, and a run is stopped after one hour.
- Missed starts. A run that could not start within 5 minutes of its scheduled time (for example because the cluster was down) is skipped rather than run late.
- History. The last three successful and the last three failed runs are kept for a day, so their logs stay readable from the console.
- Time zone.
time_zonetakes an IANA name such asAmerica/New_York. Without it, the schedule is UTC. A schedule or time zone Kuben cannot read is refused with422.
Run now
Section titled “Run now”Run now, at the top of the app page next to the schedule, starts a run immediately from the same job template (POST …/run). It is useful after fixing a failed run, or to test a new schedule without waiting. It needs the developer role or higher. The API body may name a process; without one, Kuben runs the app’s first scheduled process.
curl -fsS -X POST "$KUBEN_URL/api/v1/projects/shop/environments/production/apps/nightly-report/run" \ -H "Authorization: Bearer $KUBEN_TOKEN" -H 'Content-Type: application/json' -d '{}'The request returns 202 with the job’s name as soon as the run is created. Follow it on the app’s Logs tab.
Turning a schedule off
Section titled “Turning a schedule off”Send "schedule": "" in a PATCH to remove the schedule; the app then needs a port to become a web process; without one it becomes a worker that keeps running.