github.com/argoproj/argo-cd@v1.8.7/docs/user-guide/auto_sync.md (about) 1 # Automated Sync Policy 2 3 Argo CD has the ability to automatically sync an application when it detects differences between 4 the desired manifests in Git, and the live state in the cluster. A benefit of automatic sync is that 5 CI/CD pipelines no longer need direct access to the Argo CD API server to perform the deployment. 6 Instead, the pipeline makes a commit and push to the Git repository with the changes to the 7 manifests in the tracking Git repo. 8 9 To configure automated sync run: 10 ```bash 11 argocd app set <APPNAME> --sync-policy automated 12 ``` 13 14 Alternatively, if creating the application an application manifest, specify a syncPolicy with an 15 `automated` policy. 16 ```yaml 17 spec: 18 syncPolicy: 19 automated: {} 20 ``` 21 22 ## Automatic Pruning 23 24 By default (and as a safety mechanism), automated sync will not delete resources when Argo CD detects 25 the resource is no longer defined in Git. To prune the resources, a manual sync can always be 26 performed (with pruning checked). Pruning can also be enabled to happen automatically as part of the 27 automated sync by running: 28 29 ```bash 30 argocd app set <APPNAME> --auto-prune 31 ``` 32 33 Or by setting the prune option to true in the automated sync policy: 34 35 ```yaml 36 spec: 37 syncPolicy: 38 automated: 39 prune: true 40 ``` 41 42 ## Automatic Pruning with Allow-Empty (v1.8) 43 44 By default (and as a safety mechanism), automated sync with prune have a protection from any automation/human errors 45 when there are no target resources. It prevents application from having empty resources. To allow applications have empty resources, run: 46 47 ```bash 48 argocd app set <APPNAME> --allow-empty 49 ``` 50 51 Or by setting the allow empty option to true in the automated sync policy: 52 53 ```yaml 54 spec: 55 syncPolicy: 56 automated: 57 prune: true 58 allowEmpty: true 59 ``` 60 61 ## Automatic Self-Healing 62 By default, changes that are made to the live cluster will not trigger automated sync. To enable automatic sync 63 when the live cluster's state deviates from the state defined in Git, run: 64 65 ```bash 66 argocd app set <APPNAME> --self-heal 67 ``` 68 69 Or by setting the self heal option to true in the automated sync policy: 70 71 ```yaml 72 spec: 73 syncPolicy: 74 automated: 75 selfHeal: true 76 ``` 77 78 ## Automated Sync Semantics 79 80 * An automated sync will only be performed if the application is OutOfSync. Applications in a 81 Synced or error state will not attempt automated sync. 82 * Automated sync will only attempt one synchronization per unique combination of commit SHA1 and 83 application parameters. If the most recent successful sync in the history was already performed 84 against the same commit-SHA and parameters, a second sync will not be attempted, unless `selfHeal` flag is set to true. 85 * If `selfHeal` flag is set to true then sync will be attempted again after self heal timeout (5 seconds by default) 86 which is controlled by `--self-heal-timeout-seconds` flag of `argocd-application-controller` deployment. 87 * Automatic sync will not reattempt a sync if the previous sync attempt against the same commit-SHA 88 and parameters had failed. 89 90 * Rollback cannot be performed against an application with automated sync enabled.