Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

epic: Refactor AgentCard controller to work with Deployments and StatefulSets #161

Closed

Description

@pdettori

As part of the epic rossoctl/rossoctl#523 we need to refactor AgentCard controller to work with Deployments and StatefulSets.

This is also tracked in rossoctl/rossoctl#555

Description

Overview

Migrate the AgentCard controller from watching the custom Agent CRD to watching standard Kubernetes workloads (Deployments and StatefulSets). This aligns with the Kagenti UI migration
where agents are now deployed directly as Deployments/StatefulSets rather than through the Agent CRD.

Motivation

  • Remove dependency on Agent CRD for agent card indexing
  • Support agents deployed as standard Kubernetes workloads
  • Enable extensibility to any workload type (Job, CronJob, etc.) without code changes
  • Follow Kubernetes conventions (Gateway API pattern)

Approach: targetRef with Duck Typing

Instead of using label selectors, the AgentCard will use an explicit targetRef field:

  apiVersion: agent.kagenti.dev/v1alpha1
  kind: AgentCard
  metadata:
    name: my-agent-card
  spec:
    targetRef:
      apiVersion: apps/v1
      kind: Deployment       # or StatefulSet, Job, etc.
      name: my-agent

Benefits:

  • Explicit reference to exactly one workload (no ambiguity)
  • Extensible to any workload type without code changes
  • Uses unstructured.Unstructured for duck typing
  • Follows Gateway API's PolicyTargetReference pattern

Design Document

See kagenti/docs/plans/migrate-agent-crd-to-workloads.md for the full migration plan.


Phases

  • Design plan to refactor AgentCard controller to work with Deployments and StatefulSets #163
  • Update AgentCard CRD #164
    • Add targetRef field with apiVersion, kind, and name
    • Deprecate label-based selector field (keep for backward compatibility)
    • Update validation to require either targetRef or selector
    • Add print columns for workload type and name
    • Update CRD documentation
  • Update AgentCardReconciler #165
    • Add getWorkloadByTargetRef() method using unstructured.Unstructured
    • Implement readiness detection for Deployments and StatefulSets
    • Update protocol label lookup to support both kagenti.io/protocol and legacy kagenti.io/agent-protocol
    • Fall back to selector if targetRef is not specified
    • Add watches for Deployments and StatefulSets
    • Update RBAC permissions
  • Update AgentCardSyncReconciler #166
    • Add watches for Deployments and StatefulSets with kagenti.io/type=agent label
    • Create AgentCards with targetRef instead of selector
    • Update owner reference handling for garbage collection
    • Migrate existing selector-based AgentCards to use targetRef
    • Handle both Agent CRD and workload sources
  • Backward Compatibility & Testing #167
    • Add --enable-legacy-agent-crd feature flag (default: true)
    • Add unit tests for duck typing and readiness detection
    • Add integration tests for Deployment/StatefulSet flows
    • Add E2E tests for full agent card sync workflow
    • Document migration path for users
    • Add deprecation warnings for selector field
  • Deprecate Agent CRD Support #168
    • Remove Agent CRD watches (when flag is disabled)
    • Clean up legacy selector-based code
    • Update documentation to reflect new approach
    • Release notes for migration

Acceptance Criteria

  • AgentCards can reference Deployments via targetRef
  • AgentCards can reference StatefulSets via targetRef
  • AgentCards are automatically created for labeled Deployments/StatefulSets
  • Existing AgentCards with selector continue to work
  • Legacy Agent CRD support works when flag is enabled
  • Owner references ensure AgentCard cleanup on workload deletion
  • Agent card data is correctly fetched from workload services

Activity

  1. self-assigned this
    on Jan 31, 2026
  2. added
    enhancement
    on Jan 31, 2026
  3. added theissue type on Jan 31, 2026
  4. removed theissue type on Feb 1, 2026
  5. changed the title [-]feature: Refactor AgentCard controller to work with Deployments and StatefulSets[/-] [+]epic: Refactor AgentCard controller to work with Deployments and StatefulSets[/+] on Feb 1, 2026
  6. moved this from Backlog to In review / Needs Testing in Rossoctl Issue Prioritizationon Feb 4, 2026
  7. rubambiza commented on Feb 9, 2026

    @rubambiza
    Contributor

    Will be removed once all other components have been migrated.

  8. mrsabath commented on Feb 16, 2026

    @mrsabath
    Member

    wait until we are convinced to be in the stable state

  9. pdettori commented on Feb 23, 2026

    @pdettori
    MemberAuthor

    this is complete

  10. moved this from In review / Needs Testing to Done in Rossoctl Issue Prioritizationon Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Epicenhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions