github.com/argoproj/argo-cd/v2@v2.10.5/docs/user-guide/resource_tracking.md (about)

     1  # Resource Tracking
     2  
     3  ## Tracking Kubernetes resources by label
     4  
     5  Argo CD identifies resources it manages by setting the application instance label to the name of the managing Application on all resources that are managed (i.e. reconciled from Git). The default label used is the well-known label `app.kubernetes.io/instance`.
     6  
     7  Example:
     8  
     9  ```yaml
    10  apiVersion: apps/v1
    11  kind: Deployment
    12  metadata:
    13    name: my-deployment
    14    namespace: default
    15    labels:
    16      app.kubernetes.io/instance: some-application
    17  ```
    18  
    19  This approach works ok in most cases, as the name of the label is standardized and can be understood by other tools in the Kubernetes ecosystem.
    20  
    21  There are however several limitations:
    22  
    23  * Labels are truncated to 63 characters. Depending on the size of the label you might want to store a longer name for your application
    24  * Other external tools might write/append to this label and create conflicts with Argo CD. For example several Helm charts and operators also use this label for generated manifests confusing Argo CD about the owner of the application
    25  * You might want to deploy more than one Argo CD instance on the same cluster (with cluster wide privileges) and have an easy way to identify which resource is managed by which instance of Argo CD
    26  
    27  ### Use custom label
    28  
    29  Instead of using the default `app.kubernetes.io/instance` label for resource tracking, Argo CD can be configured to use a custom label. Below example sets the resource tracking label to `argocd.argoproj.io/instance`.
    30  
    31  ```yaml
    32  apiVersion: v1
    33  kind: ConfigMap
    34  metadata:
    35    name: argocd-cm
    36    labels:
    37      app.kubernetes.io/name: argocd-cm
    38      app.kubernetes.io/part-of: argocd
    39  data:
    40    application.instanceLabelKey: argocd.argoproj.io/instance
    41  ```
    42  
    43  ## Additional tracking methods via an annotation
    44  
    45  >v2.2
    46  
    47  To offer more flexible options for tracking resources and solve some of the issues outlined in the previous section Argo CD can be instructed to use the following methods for tracking:
    48  
    49  1. `label` (default) - Argo CD uses the `app.kubernetes.io/instance` label
    50  1. `annotation+label` - Argo CD uses the `app.kubernetes.io/instance` label but only for informational purposes. The label is not used for tracking purposes, and the value is still truncated if longer than 63 characters. The annotation `argocd.argoproj.io/tracking-id` is used instead to track application resources. Use this for resources that you manage with Argo CD, but still need compatibility with other tools that require the instance label.
    51  1. `annotation` - Argo CD uses the `argocd.argoproj.io/tracking-id` annotation to track application resources. Use this when you don't need to maintain both the label and the annotation.
    52  
    53  Here is an example of using the annotation method for tracking resources:
    54  
    55  ```yaml
    56  apiVersion: apps/v1
    57  kind: Deployment
    58  metadata:
    59    name: my-deployment
    60    namespace: default
    61    annotations:
    62      argocd.argoproj.io/tracking-id: my-app:apps/Deployment:default/nginx-deployment
    63  ```
    64  
    65  The advantages of using the tracking id annotation is that there are no clashes any
    66  more with other Kubernetes tools and Argo CD is never confused about the owner of a resource. The `annotation+label` can also be used if you want other tools to understand resources managed by Argo CD.
    67  
    68  ## Choosing a tracking method
    69  
    70  To actually select your preferred tracking method edit the `resourceTrackingMethod` value contained inside the `argocd-cm` configmap.
    71  
    72  ```yaml
    73  apiVersion: v1
    74  kind: ConfigMap
    75  metadata:
    76    name: argocd-cm
    77    labels:
    78      app.kubernetes.io/name: argocd-cm
    79      app.kubernetes.io/part-of: argocd
    80  data:
    81    application.resourceTrackingMethod: annotation
    82  ```
    83  Possible values are `label`, `annotation+label` and `annotation` as described in the previous section.
    84  
    85  Note that once you change the value you need to sync your applications again (or wait for the sync mechanism to kick-in) in order to apply your changes.
    86  
    87  You can revert to a previous choice, by changing again the configmap.