Using ArgoCD's syncWindows feature to schedule deployments

argocd kubernetes AppProject syncWindows Project

2 min read | by Jordi Prats

Sync windows in ArgoCD allow for the scheduling of deployments within specific time frames, providing control over when application synchronization and deployments can occur. This feature is particularly useful for enforcing policies or complying with specific operational requirements, like avoiding deployments during weekends.

We can schedule the windows by setting when the window starts and how long it lasts. We can also specify the applications, clusters, and namespaces affected by the window:

apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: default
spec:
  clusterResourceWhitelist:
    - group: '*'
      kind: '*'
  destinations:
    - namespace: '*'
      server: '*'
  sourceRepos:
    - '*'
  syncWindows:
    # do not sync over the weekend
    - kind: deny
      schedule: 0 19 * * 5
      duration: 60h
      manualSync: true
      applications:
      - 'prometheus'
      - 'alertmanager'
      clusters:
      - '*'
      namespaces:
      - '*'
      timeZone: Europe/London

In the previous example we are setting the sync window to deny synchronization and deployments for the specified applications during the weekend. The window starts at 19:00 on Friday and lasts for 60 hours, ending at 07:00 on Monday. In this example The applications affected by this window are prometheus and alertmanager. The window applies to all clusters and namespaces and uses the Europe/London time zone.

In the sync window we can also set the manualSync field to true to allow manual synchronization during the window. This can be useful for emergency deployments or other exceptional cases.


Posted on 07/11/2024

Categories