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

🌱 Update AgentCardReconciler as part of AgentCard refactoring - #171

Merged
pdettori merged 9 commits into
rossoctl:mainfrom
pdettori:issue-165
Feb 3, 2026
Merged

pdettori merged 9 commits into
rossoctl:mainfrom
pdettori:issue-165

Conversation

@pdettori

@pdettori pdettori commented Feb 2, 2026 •

Copy link
Copy Markdown
Member

Warning

This is a stacked PR and it is based and depends on #170, which must be reviewed and merged before this PR is reviewed and merged.

Summary

Update AgentCardReconciler as part of AgentCard refactoring.

  1. New types and constants:
    • Added WorkloadInfo struct to hold workload metadata
    • Added error types ErrWorkloadNotFound and ErrNotAgentWorkload
    • Added LabelKagentiProtocol constant for the new label format
  2. Duck typing support:
    - getWorkloadByTargetRef() - fetches any workload by apiVersion/kind/name using unstructured.Unstructured
    - getWorkload() - orchestrates workload lookup (targetRef first, then selector fallback)
    - findMatchingWorkloadBySelector() - backward compatible selector-based lookup
  3. Readiness detection:
    - isWorkloadReady() - checks readiness based on workload kind
    - Supports Deployments (replicas), StatefulSets (replicas), and Agent CRD (phase)
  4. Protocol label support:
    - getWorkloadProtocol() - supports both old (kagenti.io/agent-protocol) and new (kagenti.io/protocol) labels
  5. Controller watches:
    - Added watches for Deployments and StatefulSets with agentLabelPredicate
    - Added mapWorkloadToAgentCard() handler for triggering reconciliation
  6. RBAC permissions:
    - Added get/list/watch for apps/v1 Deployments and StatefulSets
  7. Status updates:
    - Populates status.targetRef with resolved workload reference

The implementation maintains full backward compatibility with the existing selector field while enabling the new targetRef duck typing approach.

Related issue(s)

Fixes #165

🤖 Assisted by Claude Code

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

This pull request updates the AgentCardReconciler to support duck typing for standard Kubernetes workloads (Deployments and StatefulSets) while maintaining backward compatibility with the selector-based lookup and legacy Agent CRD.

Changes:

  • Added duck typing support via targetRef to reference any workload type (Deployment, StatefulSet, or Agent CRD)
  • Implemented readiness detection for different workload types using both structured and unstructured approaches
  • Added support for new protocol label (kagenti.io/protocol) with fallback to legacy label (kagenti.io/agent-protocol)
  • Added watches for Deployments and StatefulSets with agent label predicates
  • Updated RBAC permissions to include get/list/watch for Deployments and StatefulSets

Reviewed changes

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

File Description
kagenti-operator/internal/controller/agentcard_controller.go Core implementation of targetRef-based workload lookup, readiness detection for multiple workload types, dual protocol label support, and watches for Deployments/StatefulSets
kagenti-operator/config/rbac/role.yaml Added RBAC permissions for StatefulSets (get/list/watch) and updated events permissions to match kubebuilder markers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pdettori
pdettori changed the base branch from issue-164 to main February 2, 2026 18:54

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@usize

usize commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

I'll wait for this to land before we try to land #160

There are issues with CI I've been investigating. It runs fine locally for me, I'll investigate further after a few more retries and merge this PR once it completes.

@pdettori
pdettori merged commit c4c42c0 into rossoctl:main Feb 3, 2026
1 of 4 checks passed
@pdettori
pdettori deleted the issue-165 branch February 3, 2026 00:27
usize pushed a commit to kevincogan/kagenti-operator that referenced this pull request Feb 3, 2026
🌱  Update AgentCardReconciler as part of AgentCard refactoring
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Update AgentCardReconciler

4 participants