github.com/argoproj/argo-cd/v2@v2.10.9/docs/user-guide/diff-strategies.md (about) 1 # Diff Strategies 2 3 Argo CD calculates the diff between the desired state and the live 4 state in order to define if an Application is out-of-sync. This same 5 logic is also used in Argo CD UI to display the differences between 6 live and desired states for all resources belonging to an application. 7 8 Argo CD currently has 3 different strategies to calculate diffs: 9 10 - **Legacy**: This is the main diff strategy used by default. It 11 applies a 3-way diff based on live state, desired state and 12 last-applied-configuration (annotation). 13 - **Structured-Merge Diff**: Strategy automatically applied when 14 enabling Server-Side Apply sync option. 15 - **Server-Side Diff**: New strategy that invokes a Server-Side Apply 16 in dryrun mode in order to generate the predicted live state. 17 18 ## Structured-Merge Diff 19 *Current Status: [Beta][1] (Since v2.5.0)* 20 21 This is diff strategy is automatically used when Server-Side Apply 22 sync option is enabled. It uses the [structured-merge-diff][2] library 23 used by Kubernetes to calculate diffs based on fields ownership. There 24 are some challenges using this strategy to calculate diffs for CRDs 25 that define default values. After different issues were identified by 26 the community, this strategy is being discontinued in favour of 27 Server-Side Diff. 28 29 ## Server-Side Diff 30 *Current Status: [Beta][1] (Since v2.10.0)* 31 32 This diff strategy will execute a Server-Side Apply in dryrun mode for 33 each resource of the application. The response of this operation is then 34 compared with the live state in order to provide the diff results. The 35 diff results are cached and new Server-Side Apply requests to Kube API 36 are only triggered when: 37 38 - An Application refresh or hard-refresh is requested. 39 - There is a new revision in the repo which the Argo CD Application is 40 targeting. 41 - The Argo CD Application spec changed. 42 43 One advantage of Server-Side Diff is that Kubernetes Admission 44 Controllers will participate in the diff calculation. If for example 45 a validation webhook identifies a resource to be invalid, that will be 46 informed to Argo CD during the diff stage rather than during the sync 47 stage. 48 49 ### Enabling it 50 51 Server-Side Diff can be enabled at the Argo CD Controller level or per 52 Application. 53 54 **Enabling Server-Side Diff for all Applications** 55 56 Add the following entry in the argocd-cmd-params-cm configmap: 57 58 ``` 59 apiVersion: v1 60 kind: ConfigMap 61 metadata: 62 name: argocd-cmd-params-cm 63 data: 64 controller.diff.server.side: "true" 65 ... 66 ``` 67 68 Note: It is necessary to restart the `argocd-application-controller` 69 after applying this configuration. 70 71 **Enabling Server-Side Diff for one application** 72 73 Add the following annotation in the Argo CD Application resource: 74 75 ``` 76 apiVersion: argoproj.io/v1alpha1 77 kind: Application 78 metadata: 79 annotations: 80 argocd.argoproj.io/compare-options: ServerSideDiff=true 81 ... 82 ``` 83 84 **Disabling Server-Side Diff for one application** 85 86 If Server-Side Diff is enabled globally in your Argo CD instance, it 87 is possible to disable it at the application level. In order to do so, 88 add the following annotation in the Application resource: 89 90 ``` 91 apiVersion: argoproj.io/v1alpha1 92 kind: Application 93 metadata: 94 annotations: 95 argocd.argoproj.io/compare-options: ServerSideDiff=false 96 ... 97 ``` 98 99 *Note: Please report any issues that forced you to disable the 100 Server-Side Diff feature* 101 102 ### Mutation Webhooks 103 104 Server-Side Diff does not include changes made by mutation webhooks by 105 default. If you want to include mutation webhooks in Argo CD diffs add 106 the following annotation in the Argo CD Application resource: 107 108 ``` 109 apiVersion: argoproj.io/v1alpha1 110 kind: Application 111 metadata: 112 annotations: 113 argocd.argoproj.io/compare-options: IncludeMutationWebhook=true 114 ... 115 ``` 116 117 Note: This annoation is only effective when Server-Side Diff is 118 enabled. To enable both options for a given application add the 119 following annotation in the Argo CD Application resource: 120 121 ``` 122 apiVersion: argoproj.io/v1alpha1 123 kind: Application 124 metadata: 125 annotations: 126 argocd.argoproj.io/compare-options: ServerSideDiff=true,IncludeMutationWebhook=true 127 ... 128 ``` 129 130 [1]: https://github.com/argoproj/argoproj/blob/main/community/feature-status.md#beta 131 [2]: https://github.com/kubernetes-sigs/structured-merge-diff