About ArgoCD Tracking ID

Media Headquarters Service Reliability Group (SRG)@ishikawa_kumo)is.
#SRG(Service Reliability Group) mainly provides cross-sectional support for the infrastructure of our media services, improving existing services, launching new ones, contributing to OSS, etc.
This article explains ArgoCD's Tracking ID. It is a supplement to the Resource Tracking document. In the second half, we will also introduce how to use Tracking ID to solve the management problem of "Non self-referencing resources".

ArgoCD Tracking Method


ArgoCD provides three primary methods for tracking Kubernetes resources:
  • Label
    • Default Method
    • app.kubernetes.io/instance
  • Annotation
    • Recommended Method
    • argocd.argoproj.io/tracking-id
  • Label+Annotation
    • Recommended Method
    • Label and Tracking ID handled simultaneously
    • Labels are for displaying information only, and tracking is done with Annotations.
For more information, please see the official documentation:

Label vs Annotation

In many sites using ArgoCD, the default Label method is used. Default Labelis used generically and can make it difficult to identify owners when managing resources.
In addition, there is a 63-character limit for labels on Kubernetes resources. Of course, most organizations will not use labels that exceed 63 characters, but we recommend using the annotation method because annotation or label+annotation has a better effect than the label method when dealing with "non-self-referencing" resources as described in this article.
If you absolutely must use a Label, we recommend using CustomLabel. For example,Below is an example of setting CustomLabel.
For your reference, in a vote by ArgoCon participants in 2024, Resource Tracking (Annotation method) was unanimously rated as the "default setting" in the "Tier Ranking" of ArgoCD settings. For details, please see the following article:

About Tracking ID


Annotation tracking has been added since argocd v2.2. ArgoCD, which uses Annotation or Label+Annotation, can track all managed resources.The following annotation will be added.

Tracking ID format

The Tracking ID format is as follows:
<application-name>:<group>/<kind>:<namespace>/<name>
<application-name>

Tracking ID Utilization: UI monitoring of non-self-referencing resources


What are non-self-referencing resources?

In ArgoCD, a "non self-referencing" resource is one whose tracking ID does not refer to itself.
For example, here is an example of self-referencing:
argocd.argoproj.io/tracking-id: dev-fluent-bit:apps/DaemonSet:fluent-bit/fluent-bit
As you can see, this is a Fluent Bit DaemonSet. Of it, we get the following information:
  • dev-fluent-bit
  • apps
  • DaemonSet
  • fluent-bit
  • fluent-bit
DaemonSet
On the other hand, if the Tracking ID points to another API resource, like this example, it is a non-self-referencing resource:
VirtualService
tracking-id
In fact, in cases like KubeVela mentioned above, where the manifests of actual resources are generated and managed by a separate Application Controller and ArgoCD only manages KubeVela's custom resources, most resources are non-self-referencing resources.

So what does that mean?

Due to the specifications of the ArgoCD Application Controller, all non-self-referencing resources are excluded from monitoring.In other words, non-self-referencing resources are simply displayed in the UI and do not affect the Sync Status of the ArgoCD Application in any way.
however,If you select Label as the Resource Tracking method, all resources are treated as Self Referencing resources.Non self-referencing resources are identified only if the Resource Tracking method is Annotation or Label+Annotation.
OutOfSync
Below is an example using the Label and Annotation methods.
  • OutOfSync
  • If you change it to Annotation, it will be all green.

Bonus: Understanding Prune from Source Code

ArgoCD ApplicationRepresents the status of each resourcestructurehas an item called RequiresPrune.
A function in the Application Controller that compares the current manifest of the application with the actual manifest.CompareAppStateSo, RequiresPrune is evaluated as follows:
isSelfReferencedObj
isSelfReferencedObj
true

Conclusion


This concludes the supplementary explanation of the Resource Tracking documentation. Tracking ID is a very useful feature and is already being used in many of our projects. We hope you will consider using it in your projects as well.
SRG is looking for people to work with us. If you are interested, please contact us here.