Skip to content

argocd: Add Application Resource Tree Map - #1176

Open
Joshna907 wants to merge 4 commits into
headlamp-k8s:mainfrom
Joshna907:codex/argocd-application-resource-tree
Open

argocd: Add Application Resource Tree Map#1176
Joshna907 wants to merge 4 commits into
headlamp-k8s:mainfrom
Joshna907:codex/argocd-application-resource-tree

Conversation

@Joshna907

@Joshna907 Joshna907 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds an Argo CD Application resource-tree integration to Headlamp's standard Map page. Applications appear as topology roots connected to the Kubernetes resources reported in Application.status.resources. An optional AppProject hierarchy source adds AppProject -> Application -> managed resources without changing the default Applications-only view.

The implementation preserves Headlamp's native resource experience for verified local objects and treats remote, unsupported, or unresolved objects as safe read-only nodes.

Why the standard Map page?

The Application detail page already provides GitOps Summary, Managed Resources, Sync Policy, Sync History, and Conditions. Topology and relationships belong in Headlamp's existing Map instead of adding a duplicate resource-tree section to the Application detail page.

Why strict local and remote handling?

Argo CD managed-resource references do not contain live Kubernetes UIDs or owner references. The selected Headlamp cluster is therefore used only when an Application explicitly targets https://kubernetes.default.svc or the in-cluster destination. Every other destination is treated as remote or unverified so a same-named object in the wrong cluster is never opened.

Changes

Added

  • src/components/applications/resourceTree.ts — Pure graph construction helpers for resource identity, local/remote safety, live-object matching, synthetic nodes, deduplication, Argo CD management edges, AppProject hierarchy edges, and UID-only Kubernetes owner edges.
  • src/components/applications/resourceTree.test.ts — Unit coverage for local and remote resolution, descriptor matching, synthetic nodes, ownership, shared resources, project isolation, deduplication, and compact graph content.
  • src/components/applications/statusHelpers.test.ts — Graph-status priority and partial-status tests.
  • src/mapView.tsx — Public Headlamp Map sources for Applications and the optional AppProject hierarchy overlay, using fixed supported resource classes.
  • src/mapView.test.tsx — Source loading, missing-CRD, hierarchy-status, and empty-graph tests.

Changed

  • src/components/applications/statusHelpers.ts — Added graph-specific success, warning, and error status mapping.
  • src/index.tsx — Registers both Map sources and offline Argo icons for Application and AppProject nodes.
  • src/index.test.tsx — Verifies the Map sources are registered exactly once and keeps the existing route, sidebar, CRD-guard, AppProject, and Namespace GitOps Insights assertions.

Map behavior

  • Applications is enabled by default and shows Application -> managed resource relationships.
  • AppProject hierarchy overlay is optional and disabled by default. It adds AppProject nodes and contains edges while reusing Application nodes from the Applications source.
  • Resolved local resources use their real Kubernetes UIDs and open Headlamp's native detail views.
  • Remote, unsupported, missing, and unresolved resources remain visible as read-only synthetic nodes without a kubeObject or native detail link.
  • Kubernetes ownership edges are created only when a real child ownerReferences UID matches another resolved local node.
  • Concise relationship labels distinguish contains, manages, and owns.
  • Application and AppProject nodes use the plugin's existing offline Argo icon.

Supported resource resolution

The source uses fixed useList() calls for standard Headlamp resource classes: Deployment, StatefulSet, DaemonSet, ReplicaSet, Job, CronJob, Pod, Service, ConfigMap, Secret, PersistentVolumeClaim, Ingress, NetworkPolicy, and HorizontalPodAutoscaler. Certificate and Rollout are resolved only when their optional CRDs are available. Other managed resources remain safe synthetic nodes.

Validation

  • Prettier formatting check passed.
  • ESLint passed with zero warnings.
  • TypeScript passed with no emit.
  • All 6 test files and 50 tests passed.
  • Production build passed.

Screenshots

image image

Steps to Test

  1. Have a running Kubernetes cluster with Argo CD installed and at least one Application.
  2. Build and install the local plugin, then open Headlamp's Map page.
  3. Open the source selector and verify Argo CD -> Applications is enabled.
  4. Select the Application namespace and confirm an Application root is connected to its managed resources.
  5. Select the Application node and confirm its existing Argo CD detail view opens.
  6. Select a resolved local Deployment or Service and confirm Headlamp's native Kubernetes detail view opens.
  7. Enable AppProject hierarchy overlay and confirm AppProject -> Application -> resources.
  8. Verify a remote or unverified Application has synthetic children marked Remote and those children do not open local details.
  9. Verify Map status filtering reflects Healthy, Progressing, OutOfSync, and Degraded states.
  10. When real owner references exist among resolved resources, confirm owns edges appear. Matching names or labels alone must not create ownership edges.

Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
@Joshna907
Joshna907 force-pushed the codex/argocd-application-resource-tree branch from d18abd9 to 3dec49d Compare August 14, 2026 12:59
@illume
illume requested a balanced review from Copilot August 15, 2026 10:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Argo CD Application topology to Headlamp’s Map, including optional AppProject hierarchy and safe synthetic nodes.

Changes:

  • Builds Application, managed-resource, ownership, and AppProject graphs.
  • Registers Map sources and Argo resource icons.
  • Adds graph status mapping and unit coverage.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
argocd/src/mapView.tsx Defines Argo CD Map sources.
argocd/src/mapView.test.tsx Tests source loading and configuration.
argocd/src/index.tsx Registers Map source and kind icons.
argocd/src/index.test.tsx Tests new registrations.
argocd/src/components/applications/statusHelpers.ts Maps Argo statuses to graph statuses.
argocd/src/components/applications/statusHelpers.test.ts Tests graph status mapping.
argocd/src/components/applications/resourceTree.ts Constructs Application and AppProject graphs.
argocd/src/components/applications/resourceTree.test.ts Tests graph construction and safety behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread argocd/src/components/applications/resourceTree.ts
Comment thread argocd/src/components/applications/resourceTree.ts Outdated
Signed-off-by: Joshna907 <joshnawaikar@gmail.com>
@Joshna907
Joshna907 force-pushed the codex/argocd-application-resource-tree branch from b6644b4 to 85dbab7 Compare August 15, 2026 11:06
@Joshna907

Copy link
Copy Markdown
Contributor Author

ptal @illume

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Suppressed comments (3)

argocd/src/mapView.tsx:63

  • Because this source is enabled by default, this unfiltered Pod.useList() performs a cluster-wide Pod list/watch whenever the Map is opened, even when displayed Applications reference no Pods. On large clusters this can dominate network, memory, and graph-loading cost; resolve only GVK/namespace/name descriptors reported by the Applications (leaving failures synthetic), or make this high-cardinality live resolution opt-in.
    const [pods, podError] = Pod.useList();

argocd/src/components/applications/resourceTree.ts:239

  • This same-namespace requirement drops valid Argo CD “Applications in any namespace” relationships. In that mode, the Application lives in an allowed source namespace while its referenced AppProject remains in the Argo CD control-plane namespace, so the hierarchy will leave those Applications as roots (including references to the default project). Match projects using Argo CD’s project/source-namespace rules rather than requiring equal Kubernetes namespaces.
    const projectApplications = applications.filter(
      application =>
        application.metadata.namespace === project.metadata.namespace &&
        (application.spec.project || 'default') === project.metadata.name
    );

argocd/src/index.tsx:199

  • This kind-only fallback is global, so any non-Argo CRD whose kind is also Application will receive the Argo CD icon. The Argo graph node already supplies icon: argoIcon, and the preceding group-qualified registration covers normal Argo objects; remove this fallback rather than misidentifying unrelated Application resources.
registerKindIcon('Application', { icon: argoIcon, color: ARGO_ICON_COLOR });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants