Skip to content

🌱 Refactor Kagenti UI to use standard Kubernetes workloads instead of Agent CRD - #545

Merged
pdettori merged 27 commits into
rossoctl:mainfrom
pdettori:issue-544
Jan 27, 2026
Merged

pdettori merged 27 commits into
rossoctl:mainfrom
pdettori:issue-544

Conversation

@pdettori

@pdettori pdettori commented Jan 23, 2026 •

Copy link
Copy Markdown
Member

Summary

This pull request refactors the Kagenti UI to use standard Kubernetes workloads (Deployments, StatefulSets, Jobs) instead of the custom Agent CRD, removing the dependency on kagenti-operator for agent deployment. This is a significant architectural change that aims to improve portability and leverage standard Kubernetes primitives.

##Changes:

  • Added comprehensive backend support for managing Deployments, StatefulSets, Jobs, and Services directly through Kubernetes APIs
  • Implemented migration tooling (CLI script and API endpoints) to convert existing Agent CRDs to Deployments
  • Updated frontend to display workload type information and handle multiple workload types with appropriate status indicators
  • Added RBAC permissions for workload management and updated CI/CD workflows to use the new deployment approach

Target Architecture

┌─────────────┐     POST /agents     ┌─────────────────┐
│  Kagenti UI │ ──────────────────▶  │ Backend (FastAPI)│
└─────────────┘                      └────────┬────────┘
                                              │
                                              │ Creates directly
                                              ▼
                                     ┌─────────────────┐
                                     │  Kubernetes API │
                                     └────────┬────────┘
                                              │
                              ┌───────────────┼───────────────┐
                              │               │               │
                       ┌──────▼──────┐ ┌─────▼─────┐ ┌───────▼───────┐
                       │  Deployment │ │  Service  │ │  HTTPRoute    │
                       └─────────────┘ └───────────┘ └───────────────┘

Benefits

  1. No operator dependency - Agents work without kagenti-operator running
  2. Standard K8s primitives - Better tooling support (kubectl, Lens, etc.)
  3. Simpler debugging - Direct inspection of Deployments/Services
  4. Future flexibility - Easy to add StatefulSets, Jobs, CronJobs

3. Label Standards

Required Labels (All Workloads)

All agent workloads (Deployment, StatefulSet, Job) and their managed Pods MUST have:

Label Value Purpose
kagenti.io/type agent Identifies resource as a Kagenti agent
app.kubernetes.io/name <agent-name> Standard K8s app name label
kagenti.io/protocol a2a Protocol type (a2a, mcp, etc.)

Recommended Labels

Label Value Purpose
app.kubernetes.io/managed-by kagenti-ui Resource manager
app.kubernetes.io/component agent Component type
kagenti.io/framework <framework> Framework (LangGraph, CrewAI, etc.)
kagenti.io/workload-type deployment Workload type (deployment/statefulset/job)

Phases

│ Phase │      Description       │                           Scope                            │
├───────┼────────────────────────┼────────────────────────────────────────────────────────────┤
│ 1     │ Backend Infrastructure │ Add K8s core API methods, constants, manifest builders     │
├───────┼────────────────────────┼────────────────────────────────────────────────────────────┤
│ 2     │ Deployment Support     │ Full CRUD for Deployments + Services, update all endpoints │
├───────┼────────────────────────┼────────────────────────────────────────────────────────────┤
│ 3     │ Frontend Updates       │ Update types, pages, and forms                             │
├───────┼────────────────────────┼────────────────────────────────────────────────────────────┤
│ 4     │ Migration Tooling      │ Scripts/endpoints to migrate existing Agent CRDs           │
├───────┼────────────────────────┼────────────────────────────────────────────────────────────┤
│ 5     │ Future Workloads       │ Placeholder for StatefulSet and Job support                │
└───────┴────────────────────────┴────────────────────────────────────────────────────────────┘

Related issue(s)

Fixes #544

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 refactors the Kagenti UI to use standard Kubernetes workloads (Deployments, StatefulSets, Jobs) instead of the custom Agent CRD, removing the dependency on kagenti-operator for agent deployment. This is a significant architectural change that aims to improve portability and leverage standard Kubernetes primitives.

Changes:

  • Added comprehensive backend support for managing Deployments, StatefulSets, Jobs, and Services directly through Kubernetes APIs
  • Implemented migration tooling (CLI script and API endpoints) to convert existing Agent CRDs to Deployments
  • Updated frontend to display workload type information and handle multiple workload types with appropriate status indicators
  • Added RBAC permissions for workload management and updated CI/CD workflows to use the new deployment approach

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 28 comments.

Show a summary per file
File Description
kagenti/backend/app/services/kubernetes.py Added AppsV1Api and BatchV1Api clients with CRUD methods for Deployments, Services, StatefulSets, and Jobs
kagenti/backend/app/routers/agents.py Refactored agent endpoints to create/manage workloads directly; added migration endpoints for Agent CRD to Deployment conversion
kagenti/backend/app/core/constants.py Added workload type constants and migration-related annotations
kagenti/backend/app/core/config.py Added enable_legacy_agent_crd setting for backward compatibility during migration period
kagenti/backend/app/models/responses.py Added workloadType field to AgentSummary response model
kagenti/tools/migrate_agents.py New CLI tool for migrating Agent CRDs to Deployments with dry-run support
kagenti/backend/tests/test_migration.py Unit tests for migration manifest builders
kagenti/ui-v2/src/types/index.ts Added WorkloadType, DeploymentStatus, ServiceInfo, and ContainerSpec interfaces
kagenti/ui-v2/src/services/api.ts Added workloadType field to agent creation request
kagenti/ui-v2/src/pages/AgentCatalogPage.tsx Added workload type column and updated status badge rendering
kagenti/ui-v2/src/pages/AgentDetailPage.tsx Enhanced detail view with workload type, replica info, and service information
kagenti/ui-v2/src/pages/ImportAgentPage.tsx Added workload type selector with helper text
charts/kagenti/templates/ui.yaml Added RBAC permissions for Deployments, StatefulSets, Jobs, and Services
.github/workflows/e2e-kind.yaml Updated comments to reflect new deployment approach
.github/scripts/kagenti-operator/74-deploy-weather-agent.sh Modified to deploy using Deployment + Service instead of Agent CRD
.github/scripts/kagenti-operator/41-wait-crds.sh Removed Agent CRD from required CRDs list
docs/plans/migrate-agent-crd-to-workloads.md Comprehensive migration plan documentation

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

Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/tools/migrate_agents.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/backend/tests/test_migration.py Resolved
Comment thread kagenti/backend/app/routers/agents.py Resolved
Comment thread kagenti/tools/migrate_agents.py Resolved
@pdettori

Copy link
Copy Markdown
Member Author

Here are some screenshots using the new model:

image image image

@rubambiza

Copy link
Copy Markdown
Contributor

@pdettori Is there anyone on the team you'd like to take a look at (maybe a subset?) of the 5000+ changes? I'd be willing to kick the tires as usual if given instructions 😃

@pdettori

pdettori commented Jan 26, 2026 •

Copy link
Copy Markdown
Member Author

How to test:

  1. Delete existing agents, agentbuilds, builds, buildruns from your dev namespaces (team1, team2)
  2. pull this PR in your local env
  3. Install Kagenti as usual with deployments/ansible/run-install.sh --env dev (use the --preload flag if needed)
  4. Run the command make build-load-ui
  5. Copy and paste and run the helm command printed at the end of the build and load.
  6. Check the new UI and backend starts with: kubectl get pods -n kagenti-system
  7. Now follow the usual flow to build and run an agent, making sure to import the env variables for the agent

@pdettori

Copy link
Copy Markdown
Member Author

@rubambiza ^^^ some instructions if you wan to try

@cwiklik
cwiklik self-requested a review January 26, 2026 19:50
@cwiklik

cwiklik commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

@pdettori I can deploy weather agent and tool both from source and image. When I delete (agent or tool), echo the name and confirm delete, I still see the agent (or tool) listed. I have to refresh to see it gone.

pdettori and others added 16 commits January 26, 2026 17:41
Signed-off-by: Paolo Dettori <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>

Co-authored-by: Copilot <[email protected]>
@rubambiza

Copy link
Copy Markdown
Contributor

@pdettori A couple of things I noticed:

  • The --preload is failing when I install with no pre-existing kind cluster. I recall we have observed this before, but it is likely some checks may have shifted in the refactoring. Once I created the cluster before running the installer, the installation proceeded as expected.
  • For pasting and running the helm command, the file charts/kagenti/.secrets.yaml does not seem to exist. Are we expected to create (and fill it with values from the old .secrets_values.yaml)?

@pdettori

Copy link
Copy Markdown
Member Author

@rubambiza thanks for your feedback. Re kind cluster - this is unrelated to this PR, there is an open issue in #491 which we should address independently.

As for the helm command - the installation instructions ask to create that file from the template.

@pdettori

Copy link
Copy Markdown
Member Author

@cwiklik thanks for opening #551 - we will track there the issue with delete refresh, since as discussed offline that is unrelated to this specific PR.

@cwiklik cwiklik 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.

Installed from the PR
Was able to deploy a weather agent and MCP tool, and use a prompt to ask for weather which worked.
lgtm

@rubambiza rubambiza 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.

Tested the installation with the refactored code. LGTM.

@pdettori
pdettori merged commit 6e303cc into rossoctl:main Jan 27, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from In review / Needs Testing to Done in Rossoctl Issue Prioritization Jan 27, 2026
@pdettori
pdettori deleted the issue-544 branch January 27, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Refactor UI to use Deployment + Service for agents.

4 participants