diff --git a/controller/sync.go b/controller/sync.go index 311e25576d53a..2b0baa57e6060 100644 --- a/controller/sync.go +++ b/controller/sync.go @@ -90,7 +90,13 @@ func (m *appStateManager) SyncAppState(appProject *v1alpha1.AppProject, app *v1a var source v1alpha1.ApplicationSource var sources []v1alpha1.ApplicationSource revisions := make([]string, 0) - projectSyncOp := appProject.Spec.SyncPolicy.SyncOptions + var projectSyncOp v1alpha1.SyncOptions + + if appProject.Spec.SyncPolicy != nil { + projectSyncOp = appProject.Spec.SyncPolicy.SyncOptions + } else { + projectSyncOp = nil + } if state.Operation.Sync == nil { state.Phase = common.OperationFailed diff --git a/docs/operator-manual/project.yaml b/docs/operator-manual/project.yaml index c4d93f536239f..71692a2a5ae80 100644 --- a/docs/operator-manual/project.yaml +++ b/docs/operator-manual/project.yaml @@ -86,6 +86,36 @@ spec: clusters: - in-cluster - cluster1 + + # Sync policy + syncPolicy: + automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field. + prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ). + selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ). + allowEmpty: false # Allows deleting all application resources during automatic syncing ( false by default ). + syncOptions: # Sync options which modifies sync behavior + - Validate=false # disables resource validation (equivalent to 'kubectl apply --validate=false') ( true by default ). + - CreateNamespace=true # Namespace Auto-Creation ensures that namespace specified as the application destination exists in the destination cluster. + - PrunePropagationPolicy=foreground # Supported policies are background, foreground and orphan. + - PruneLast=true # Allow the ability for resource pruning to happen as a final, implicit wave of a sync operation + - RespectIgnoreDifferences=true # When syncing changes, respect fields ignored by the ignoreDifferences configuration + - ApplyOutOfSyncOnly=true # Only sync out-of-sync resources, rather than applying every object in the application + managedNamespaceMetadata: # Sets the metadata for the application namespace. Only valid if CreateNamespace=true (see above), otherwise it's a no-op. + labels: # The labels to set on the application namespace + any: label + you: like + annotations: # The annotations to set on the application namespace + the: same + applies: for + annotations: on-the-namespace + + # The retry feature is available since v1.7 + retry: + limit: 5 # number of failed sync attempt retries; unlimited number of attempts if less than 0 + backoff: + duration: 5s # the amount to back off. Default unit is seconds, but could also be a duration (e.g. "2m", "1h") + factor: 2 # a factor to multiply the base duration after each failed retry + maxDuration: 3m # the maximum amount of time allowed for the backoff strategy # By default, apps may sync to any cluster specified under the `destinations` field, even if they are not # scoped to this project. Set the following field to `true` to restrict apps in this cluster to only clusters