github.com/argoproj/argo-cd/v3@v3.2.1/docs/operator-manual/reconcile.md (about)

     1  # Reconcile Optimization
     2  
     3  By default, an Argo CD Application is refreshed every time a resource that belongs to it changes.
     4  
     5  Kubernetes controllers often update the resources they watch periodically, causing continuous reconcile operation on the Application
     6  and a high CPU usage on the `argocd-application-controller`. Argo CD allows you to optionally ignore resource updates on specific fields
     7  for [tracked resources](../user-guide/resource_tracking.md).
     8  For untracked resources, you can [use the argocd.argoproj.io/ignore-resource-updates annotations](#ignoring-updates-for-untracked-resources)
     9  
    10  When a resource update is ignored, if the resource's [health status](./health.md) does not change, the Application that this resource belongs to will not be reconciled.
    11  
    12  ## System-Level Configuration
    13  
    14  By default, `resource.ignoreResourceUpdatesEnabled` is set to `true`, enabling Argo CD to ignore resource updates. This default setting ensures that Argo CD maintains sustainable performance by reducing unnecessary reconcile operations. If you need to alter this behavior, you can explicitly set `resource.ignoreResourceUpdatesEnabled` to `false` in the `argocd-cm` ConfigMap:
    15  
    16  ```yaml
    17  apiVersion: v1
    18  kind: ConfigMap
    19  metadata:
    20    name: argocd-cm
    21    namespace: argocd
    22  data:
    23    resource.ignoreResourceUpdatesEnabled: 'false'
    24  ```
    25  
    26  Argo CD allows ignoring resource updates at a specific JSON path, using [RFC6902 JSON patches](https://tools.ietf.org/html/rfc6902) and [JQ path expressions](<https://stedolan.github.io/jq/manual/#path(path_expression)>). It can be configured for a specified group and kind
    27  in `resource.customizations` key of the `argocd-cm` ConfigMap.
    28  
    29  Following is an example of a customization which ignores the `refreshTime` status field of an [`ExternalSecret`](https://external-secrets.io/main/api/externalsecret/) resource:
    30  
    31  ```yaml
    32  data:
    33    resource.customizations.ignoreResourceUpdates.external-secrets.io_ExternalSecret:
    34      |
    35      jsonPointers:
    36      - /status/refreshTime
    37      # JQ equivalent of the above:
    38      # jqPathExpressions:
    39      # - .status.refreshTime
    40  ```
    41  
    42  It is possible to configure `ignoreResourceUpdates` to be applied to all tracked resources in every Application managed by an Argo CD instance. In order to do so, resource customizations can be configured like in the example below:
    43  
    44  ```yaml
    45  data:
    46    resource.customizations.ignoreResourceUpdates.all: |
    47      jsonPointers:
    48      - /status
    49  ```
    50  
    51  ### Using ignoreDifferences to ignore reconcile
    52  
    53  By default, the existing system-level `ignoreDifferences` customizations will be added to ignore resource updates as well. This helps reduce config management by preventing you to copy all existing ignore differences configurations.
    54  
    55  To disable this behavior, the `ignoreDifferencesOnResourceUpdates` setting can be disabled:
    56  
    57  ```yaml
    58  apiVersion: v1
    59  kind: ConfigMap
    60  metadata:
    61    name: argocd-cm
    62  data:
    63    resource.compareoptions: |
    64      ignoreDifferencesOnResourceUpdates: false
    65  ```
    66  
    67  ## Default Configuration
    68  
    69  By default, the metadata fields `generation`, `resourceVersion` and `managedFields` are always ignored for all resources.
    70  
    71  ## Finding Resources to Ignore
    72  
    73  The application controller logs when a resource change triggers a refresh. You can use these logs to find
    74  high-churn resource kinds and then inspect those resources to find which fields to ignore.
    75  
    76  To find these logs, search for `"Requesting app refresh caused by object update"`. The logs include structured
    77  fields for `api-version` and `kind`. Counting the number of refreshes triggered, by api-version/kind should
    78  reveal the high-churn resource kinds.
    79  
    80  !!! note
    81      These logs are at the `debug` level. Configure the application-controller's log level to `debug`.
    82  
    83  Once you have identified some resources which change often, you can try to determine which fields are changing. Here is
    84  one approach:
    85  
    86  ```shell
    87  kubectl get <resource> -o yaml > /tmp/before.yaml
    88  # Wait a minute or two.
    89  kubectl get <resource> -o yaml > /tmp/after.yaml
    90  diff /tmp/before.yaml /tmp/after.yaml
    91  ```
    92  
    93  The diff can give you a sense for which fields are changing and should perhaps be ignored.
    94  
    95  ## Checking Whether Resource Updates are Ignored
    96  
    97  Whenever Argo CD skips a refresh due to an ignored resource update, the controller logs the following line:
    98  "Ignoring change of object because none of the watched resource fields have changed".
    99  
   100  Search the application-controller logs for this line to confirm that your resource ignore rules are being applied.
   101  
   102  !!! note
   103      These logs are at the `debug` level. Configure the application-controller's log level to `debug`.
   104  
   105  ## Examples
   106  
   107  ### argoproj.io/Application
   108  
   109  ```yaml
   110  apiVersion: v1
   111  kind: ConfigMap
   112  metadata:
   113    name: argocd-cm
   114  data:
   115    resource.customizations.ignoreResourceUpdates.argoproj.io_Application: |
   116      jsonPointers:
   117      # Ignore when ownerReferences change, for example when a parent ApplicationSet changes often.
   118      - /metadata/ownerReferences
   119      # Ignore reconciledAt, since by itself it doesn't indicate any important change.
   120      - /status/reconciledAt
   121      jqPathExpressions:
   122      # Ignore lastTransitionTime for conditions; helpful when SharedResourceWarnings are being regularly updated but not
   123      # actually changing in content.
   124      - .status?.conditions[]?.lastTransitionTime
   125  ```
   126  
   127  ## Ignoring updates for untracked resources
   128  
   129  ArgoCD will only apply `ignoreResourceUpdates` configuration to tracked resources of an application. This means dependant resources, such as a `ReplicaSet` and `Pod` created by a `Deployment`, will not ignore any updates and trigger a reconcile of the application for any changes.
   130  
   131  If you want to apply the `ignoreResourceUpdates` configuration to an untracked resource, you can add the
   132  `argocd.argoproj.io/ignore-resource-updates=true` annotation in the dependent resources manifest.
   133  
   134  ## Example
   135  
   136  ### CronJob
   137  
   138  ```yaml
   139  apiVersion: batch/v1
   140  kind: CronJob
   141  metadata:
   142    name: hello
   143    namespace: test-cronjob
   144  spec:
   145    schedule: '* * * * *'
   146    jobTemplate:
   147      metadata:
   148        annotations:
   149          argocd.argoproj.io/ignore-resource-updates: 'true'
   150      spec:
   151        template:
   152          metadata:
   153            annotations:
   154              argocd.argoproj.io/ignore-resource-updates: 'true'
   155          spec:
   156            containers:
   157              - name: hello
   158                image: busybox:1.28
   159                imagePullPolicy: IfNotPresent
   160                command:
   161                  - /bin/sh
   162                  - -c
   163                  - date; echo Hello from the Kubernetes cluster
   164            restartPolicy: OnFailure
   165  ```
   166  
   167  The resource updates will be ignored based on your the `ignoreResourceUpdates` configuration in the `argocd-cm` configMap:
   168  
   169  `argocd-cm`:
   170  
   171  ```yaml
   172  resource.customizations.ignoreResourceUpdates.batch_Job: |
   173    jsonPointers:
   174      - /status
   175  resource.customizations.ignoreResourceUpdates.Pod: |
   176    jsonPointers:
   177      - /status
   178  ```