5-Spot uses flexible schedule configurations to determine when machines should be active.
Since ADR 0009, a
ScheduledMachine.spec.scheduleis a reference to a spot-schedule provider object — it no longer carries the day/hour window inline. The day/hour/timezone grammar described on this page now lives on the default first-party provider,TimeBasedSpotSchedule(see the provider guide). The grammar is unchanged; only its home moved. Allspec:snippets below areTimeBasedSpotSchedulespecs.
A TimeBasedSpotSchedule schedules machines using day and hour ranges.
Use daysOfWeek and hoursOfDay on a TimeBasedSpotSchedule to define when a
machine should be active:
apiVersion: spotschedules.5spot.finos.org/v1alpha1
kind: TimeBasedSpotSchedule
metadata:
name: business-hours
namespace: default
spec:
daysOfWeek:
- mon-fri
hoursOfDay:
- 9-17
timezone: America/New_York
enabled: trueA ScheduledMachine then references it:
spec:
enabled: true
schedule:
apiVersion: spotschedules.5spot.finos.org/v1alpha1
kind: TimeBasedSpotSchedule
name: business-hoursmon,tue,wed,thu,fri,sat,sun
Use a hyphen to specify ranges:
daysOfWeek:
- mon-fri # Monday through FridayCombine ranges and individual days:
daysOfWeek:
- mon-wed
- fri
- sunRanges can wrap around the week:
daysOfWeek:
- fri-mon # Friday, Saturday, Sunday, Monday| Configuration | Active Days |
|---|---|
[mon-fri] |
Monday - Friday |
[sat-sun] |
Saturday - Sunday |
[mon, wed, fri] |
Monday, Wednesday, Friday |
[mon-wed, fri-sun] |
Mon-Wed and Fri-Sun |
[fri-tue] |
Fri, Sat, Sun, Mon, Tue (wrap-around) |
Hours are specified in 24-hour format (0-23).
Ranges are inclusive of both start and end:
hoursOfDay:
- 9-17 # Active from 9:00 to 17:59hoursOfDay:
- 0-8
- 18-23
# Active outside business hoursHours can wrap around midnight:
hoursOfDay:
- 22-6 # 10pm to 6am (overnight)| Configuration | Active Hours |
|---|---|
[9-17] |
9:00 AM - 5:59 PM |
[0-23] |
All day (24 hours) |
[0-8, 18-23] |
Night shift |
[6-12, 14-20] |
Two shifts with lunch break |
[22-6] |
Overnight (10pm - 6am) |
Use standard IANA timezone names:
timezone: America/New_York
timezone: Europe/London
timezone: Asia/Tokyo
timezone: UTC| Timezone | UTC Offset | Region |
|---|---|---|
UTC |
+00:00 | Universal |
America/New_York |
-05:00 | US Eastern |
America/Los_Angeles |
-08:00 | US Pacific |
Europe/London |
+00:00 | UK |
Europe/Paris |
+01:00 | Central Europe |
Asia/Tokyo |
+09:00 | Japan |
Timezones automatically handle DST transitions:
America/New_Yorkadjusts for EDT/ESTEurope/Londonadjusts for BST/GMT
There are two distinct enabled switches — keep them separate:
TimeBasedSpotSchedule.spec.enabled(the provider's own toggle): setfalseto force the provider'sstatus.activetofalse(the window is ignored) without deleting the schedule. EveryScheduledMachinereferencing it then sees an inactive provider.ScheduledMachine.spec.enabled(the administrative master switch): setfalseto hold that one machine in theDisabledphase regardless of what its provider reports. This is also the loop-breaker the emergency-reclaim flow sets.
apiVersion: spotschedules.5spot.finos.org/v1alpha1
kind: TimeBasedSpotSchedule
spec:
enabled: false
# ... daysOfWeek / hoursOfDay / timezone preservedWhen the provider is disabled (status.active: false):
- Existing active machines that reference it gracefully shut down
- No new activations occur
Set ScheduledMachine.spec.enabled: false instead to administratively park a
single machine in the Disabled phase.
- Maintenance windows: Temporarily disable scheduling
- Emergency situations: Quick pause without config changes
- Testing: Disable specific machines during tests
schedule:
daysOfWeek: [mon-fri]
hoursOfDay: [9-17]
timezone: America/New_Yorkschedule:
daysOfWeek: [mon-sun]
hoursOfDay: [0-23]
timezone: UTC# Wrap-around hour ranges are supported
schedule:
daysOfWeek: [mon-fri]
hoursOfDay: [18-23, 0-6]
timezone: UTCschedule:
daysOfWeek: [sat-sun]
hoursOfDay: [0-23]
timezone: UTCschedule:
daysOfWeek: [mon-fri]
hoursOfDay: [8-10, 16-18]
timezone: America/Los_AngelesEvaluation is event-driven, split across two controllers (ADR 0009). The
TimeBasedSpotSchedule provider controller computes status.active from the
window and requeues once at the next window boundary (no polling). 5-Spot's
main controller watches the referenced provider and reacts to its
status.active flips at watch latency.
flowchart TD
A[TimeBasedSpotSchedule controller<br/>reconcile / boundary requeue] --> B[Get Current Time]
B --> C[Convert to spec.timezone]
C --> D{spec.enabled?}
D -->|No| E[status.active = false]
D -->|Yes| H{Day in daysOfWeek?}
H -->|No| E
H -->|Yes| K{Hour in hoursOfDay?}
K -->|No| E
K -->|Yes| I[status.active = true]
E --> P[PATCH status.active]
I --> P
P --> W[5-Spot watch wakes referencing machines]
W --> X{ScheduledMachine.spec.enabled<br/>and not killSwitch?}
X -->|active and enabled| L[Create/Maintain Machine]
X -->|inactive or disabled| M[Remove Machine if exists]
- ScheduledMachine - CRD specification
- Machine Lifecycle - Phase transitions
- API Reference - Complete API documentation