About ArgoCD Tracking ID

Ishikawa Kumo (Service Reliability Group (SRG) of the Media Headquarters)@ishikawa_kumo)is.
#SRG(Service Reliability Group) is a group that mainly provides cross-sectional support for the infrastructure of our media services, improving existing services, launching new ones, and contributing to OSS.
This article explains ArgoCD's Tracking ID. It serves as a supplement to the Resource Tracking document. In the second half, we'll also show how to use Tracking ID to solve the problem of managing "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 are handled simultaneously
    • Labels are for information only, and tracking is done with Annotations
For more information, please refer to 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.
Furthermore, there is a 63-character limit for Kubernetes resource labels. Of course, most organizations will not use labels with more than 63 characters. However, we recommend using the Annotation method because Annotation or Label+Annotation can provide better results than the Label method when handling "Non-self-referencing" resources, as described in this article.
If you absolutely must use Label, we recommend using CustomLabel. For example,Below is an example of setting CustomLabel.
For reference, in a vote by ArgoCon attendees in 2024, Resource Tracking (Annotation method) was unanimously rated as the "default setting" in the "Tier Ranking" of ArgoCD settings. For more 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 the resource itself.
For example, the following is an example of a self-referencing tracking ID:
argocd.argoproj.io/tracking-id: dev-fluent-bit:apps/DaemonSet:fluent-bit/fluent-bit
As you can see, this is a Fluent Bit DaemonSet, and we can get the following information from it:
  • dev-fluent-bit
  • apps
  • DaemonSet
  • fluent-bit
  • fluent-bit
DaemonSet
On the other hand, in the following example, the Tracking ID points to another API resource, which is a non-self-referencing resource:
VirtualService
tracking-id
In fact, in cases like the aforementioned KubeVela, where the actual resource manifests are generated and managed by a separate Application Controller and ArgoCD only manages KubeVela's custom resources, most resources fall under the category of 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 only 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 will be treated as Self Referencing resources.Non-self-referencing resources are identified only when 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 Application shows 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 our 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 encourage you to consider using it in your own projects.
SRG is looking for people to work with us. If you're interested, please contact us here.