The problem
Many teams have a rule like "no production deploys on Friday evening or at the weekend". Usually it lives in a wiki page, and nothing stops a late kubectl, Argo CD sync or CI job from breaking it.
A Kubernetes operator that only lets selected Deployments roll out during allowed time windows, and pauses them the rest of the time.
Many teams have a rule like "no production deploys on Friday evening or at the weekend". Usually it lives in a wiki page, and nothing stops a late kubectl, Argo CD sync or CI job from breaking it.
A DeploymentWindow names the Deployments it covers and the hours they may roll out. Outside those hours the operator sets spec.paused: true on each one, so a new image or config change waits until the window opens.
apiVersion: policy.deploywindow.dev/v1alpha1
kind: DeploymentWindow
metadata:
name: business-hours
spec:
selector:
matchLabels:
tier: prod
timeZone: Africa/Lagos
windows:
- days: [Mon, Tue, Wed, Thu, Fri]
start: "09:00"
end: "17:00"
suspend: false # true releases everything, for an emergency fixEach pass works out whether the window is open now and when that next changes. If it's closed, the operator pauses every matching Deployment and marks it with a deploywindow.dev/paused-by annotation. If it's open or suspended, it resumes only the Deployments carrying that annotation. Then it writes the status and requeues for the next boundary.
The controller also watches Deployments, so a new or relabelled one is handled at once. A finalizer makes sure that deleting a window resumes everything it paused before the object goes away. An invalid spec, such as an unknown time zone, sets Ready=False and leaves nothing paused.
A script runs the whole story on a kind cluster: a closed window pauses a tier=prod Deployment, an image change creates no new ReplicaSet, suspend: true lets the rollout finish, suspend: false pauses it again, and deleting the window resumes it.
It covers Deployments only, because StatefulSets and DaemonSets have no paused field. A window applies to one namespace and can't cross midnight, so 22:00–02:00 needs two windows. A rollout already in progress when the window closes stops where it is and finishes when the window opens.