github.com/argoproj/argo-cd/v2@v2.10.9/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  
     9  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.
    10  
    11  ## System-Level Configuration
    12  
    13  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
    14  in `resource.customizations` key of the `argocd-cm` ConfigMap.
    15  
    16  !!!important "Enabling the feature"
    17      The feature is behind a flag. To enable it, set `resource.ignoreResourceUpdatesEnabled` to `"true"` in the `argocd-cm` ConfigMap.
    18  
    19  Following is an example of a customization which ignores the `refreshTime` status field of an [`ExternalSecret`](https://external-secrets.io/main/api/externalsecret/) resource:
    20  
    21  ```yaml
    22  data:
    23    resource.customizations.ignoreResourceUpdates.external-secrets.io_ExternalSecret: |
    24      jsonPointers:
    25      - /status/refreshTime
    26      # JQ equivalent of the above:
    27      # jqPathExpressions:
    28      # - .status.refreshTime
    29  ```
    30  
    31  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:
    32  
    33  ```yaml
    34  data:
    35    resource.customizations.ignoreResourceUpdates.all: |
    36      jsonPointers:
    37      - /status
    38  ```
    39  
    40  ### Using ignoreDifferences to ignore reconcile
    41  
    42  It is possible to use existing system-level `ignoreDifferences` customizations to ignore resource updates as well. Instead of copying all configurations,
    43  the `ignoreDifferencesOnResourceUpdates` setting can be used to add all ignored differences as ignored resource updates:
    44  
    45  ```yaml
    46  apiVersion: v1
    47  kind: ConfigMap
    48  metadata:
    49    name: argocd-cm
    50  data:
    51    resource.compareoptions: |
    52      ignoreDifferencesOnResourceUpdates: true
    53  ```
    54  
    55  ## Default Configuration
    56  
    57  By default, the metadata fields `generation`, `resourceVersion` and `managedFields` are always ignored for all resources.
    58  
    59  ## Finding Resources to Ignore
    60  
    61  The application controller logs when a resource change triggers a refresh. You can use these logs to find
    62  high-churn resource kinds and then inspect those resources to find which fields to ignore.
    63  
    64  To find these logs, search for `"Requesting app refresh caused by object update"`. The logs include structured
    65  fields for `api-version` and `kind`.  Counting the number of refreshes triggered, by api-version/kind should
    66  reveal the high-churn resource kinds.
    67  
    68  !!!note 
    69      These logs are at the `debug` level. Configure the application-controller's log level to `debug`.
    70  
    71  Once you have identified some resources which change often, you can try to determine which fields are changing. Here is
    72  one approach:
    73  
    74  ```shell
    75  kubectl get <resource> -o yaml > /tmp/before.yaml
    76  # Wait a minute or two.
    77  kubectl get <resource> -o yaml > /tmp/after.yaml
    78  diff /tmp/before.yaml /tmp/after
    79  ```
    80  
    81  The diff can give you a sense for which fields are changing and should perhaps be ignored.
    82  
    83  ## Checking Whether Resource Updates are Ignored
    84  
    85  Whenever Argo CD skips a refresh due to an ignored resource update, the controller logs the following line:
    86  "Ignoring change of object because none of the watched resource fields have changed".
    87  
    88  Search the application-controller logs for this line to confirm that your resource ignore rules are being applied.
    89  
    90  !!!note
    91      These logs are at the `debug` level. Configure the application-controller's log level to `debug`.
    92  
    93  ## Examples
    94  
    95  ### argoproj.io/Application
    96  
    97  ```yaml
    98  apiVersion: v1
    99  kind: ConfigMap
   100  metadata:
   101    name: argocd-cm
   102  data:
   103    resource.customizations.ignoreResourceUpdates.argoproj.io_Application: |
   104      jsonPointers:
   105      # Ignore when ownerReferences change, for example when a parent ApplicationSet changes often.
   106      - /metadata/ownerReferences
   107      # Ignore reconciledAt, since by itself it doesn't indicate any important change.
   108      - /status/reconciledAt
   109      jqPathExpressions:
   110      # Ignore lastTransitionTime for conditions; helpful when SharedResourceWarnings are being regularly updated but not
   111      # actually changing in content.
   112      - .status.conditions[].lastTransitionTime
   113  ```