Repository navigation
Description
Problem
Summary
Implement the AgentRuntime CRD and controller in the kagenti-operator. AgentRuntime is the single source of truth for enrolling a workload into the Kagenti platform — it triggers sidecar injection and provides per-workload configuration overrides.
The operator already manages AgentCard CRs. AgentRuntime follows the same patterns (kubebuilder, controller-runtime, TargetRef duck typing) and lives alongside AgentCard in api/v1alpha1.
Motivation
Today, developers must add kagenti.io/type: agent labels to their Deployment manifests to trigger webhook injection. This creates an ownership inversion — developers modify workloads for what is fundamentally a platform concern. It also causes GitOps drift when the webhook mutates the Deployment.
With AgentRuntime:
- Developer deploys a standard workload with no kagenti labels
- Developer creates an AgentRuntime CR with
targetRefpointing to the workload - The controller applies labels to the PodTemplateSpec, triggering a rolling update
- The webhook injects sidecars at Pod CREATE time
- Developer workloads stay clean
How it works
- Developer deploys a standard Deployment (no kagenti labels)
- Developer creates an AgentRuntime CR with
targetRefpointing to the Deployment - AgentRuntime controller reconciles:
- Resolves
targetRefto the target workload - Computes a config hash from the AgentRuntime spec merged with ConfigMap defaults
- Applies
kagenti.io/type: agent|toollabel to the Deployment's PodTemplateSpec - Applies
kagenti.io/config-hash: <hash>annotation to the PodTemplateSpec - May apply labels to the Deployment metadata for UI/TUI/API discovery
- Resolves
- PodTemplateSpec change triggers a rolling update
- Kubernetes creates new Pods — the admission webhook intercepts Pod CREATE and injects sidecars
- On AgentRuntime update: config-hash changes, rolling update, webhook re-injects with new config
- On AgentRuntime delete: finalizer preserves
kagenti.io/typelabel, updates config-hash to defaults-only, rolling update redeploys with platform defaults
Scope: lean v1alpha1
The CRD is intentionally scoped to what we need for Summit. Fields not in v1alpha1 are deferred, not rejected.
In scope (v1alpha1):
spec.type—agentortoolspec.targetRef— duck-typed workload reference (reuse existingTargetReffrom AgentCard)spec.identity.spiffe.trustDomain— override SPIFFE trust domainspec.identity.clientRegistration.provider— IdP provider (keycloak)spec.identity.clientRegistration.realm— IdP realmspec.identity.clientRegistration.adminCredentialsSecret— secret referencespec.trace.endpoint— OTEL collector endpointspec.trace.protocol— grpc or httpspec.trace.sampling.rate— sampling rate (0.0-1.0)status.phase— Active, Pending, Errorstatus.configuredPods— count of pods with injected sidecarsstatus.conditions— standard metav1.Conditions
Deferred (post-Summit):
spec.trace.genai— GenAI capture (prompts, completions)spec.trace.integration— MLflow, Prometheus integrationspec.trace.exporters— multiple exporter supportspec.trace.resourceAttributes— custom OTEL resource attributes
Progress tracker
Update checkboxes as work progresses. Each item links to its sub-issue below.
Last updated: 2026-04-15. Note: webhook was migrated from kagenti-extensions into kagenti-operator (PR #261).
Phase 1: CRD and core controller
- AgentRuntime CRD definition (kagenti-operator#212)
- AgentRuntime controller — label management (kagenti-operator#218)
- Config hash computation (kagenti-operator#218, #266)
- Unit and integration tests for controller (kagenti-operator#266)
Phase 2: Webhook coordination and RBAC
- RBAC and webhook coordination (kagenti-operator#249, #253)
- Webhook updated to target Pods at CREATE time — webhook migrated into operator (kagenti-operator#261; extensions#176 closed)
- Webhook reads AgentRuntime CR for config merging (kagenti-operator#245; extensions#177 closed)
Phase 3: Helm and platform integration
- Helm chart updates — operator (kagenti-operator#261 — chart 0.2.0-alpha.24)
- Helm chart updates — platform chart (kagenti#1153 — switched to operator chart)
- Example agents updated to use AgentRuntime CRs (kagenti#1153 — backend creates/deletes AgentRuntime CRs)
Phase 4: E2E and documentation
- E2E tests on Kind (kagenti-operator#270 merged, 8 test scenarios, all CI green)
- Documentation updates (kagenti-operator#290 — GETTING_STARTED.md, architecture RBAC tables, controller-webhook interaction doc, sample YAMLs)
- Argo CD compatibility guide
Final
- All CI passing
- Design proposal updated to reflect implementation
- Demo-ready on Kind cluster (validated by E2E tests in kagenti-operator#270)
Sub-issues
1. AgentRuntime CRD definition
Repo: kagenti-operator
Path: kagenti-operator/api/v1alpha1/agentruntime_types.go
Status: Done (kagenti-operator#212, #254)
Tasks:
- Define
AgentRuntimeSpec,AgentRuntimeStatusstructs with kubebuilder markers - Reuse existing
TargetReftype fromagentcard_types.go - Add
spec.typefield with enum validation (agentortool) - Add
spec.identitysection (spiffe trustDomain, clientRegistration provider/realm/secret) - Add
spec.tracesection (endpoint, protocol, sampling rate) - Add
status.phase,status.configuredPods,status.conditions - Run
make generateandmake manifeststo generate deepcopy and CRD YAML - Add printer columns: NAME, TYPE, TARGET, PHASE, AGE
- Verify:
kubectl applythe CRD successfully - Verify:
kubectl get agentruntimeshows printer columns - Verify: CRD validation rejects invalid specs (missing targetRef, invalid type)
2. AgentRuntime controller — label management
Repo: kagenti-operator
Path: kagenti-operator/internal/controller/agentruntime_controller.go
Status: Done (kagenti-operator#218, #242)
Tasks:
- Scaffold controller with kubebuilder
- Implement reconcile loop: watch AgentRuntime CRs for create/update/delete
- Add finalizer (
kagenti.io/cleanup) on AgentRuntime creation - On create/update:
- Resolve
targetRefto find target Deployment/StatefulSet (duck typing) - Compute config hash from spec
- Apply
kagenti.io/type: <spec.type>label to PodTemplateSpec - Apply
kagenti.io/config-hash: <hash>annotation to PodTemplateSpec - Apply discovery labels to Deployment metadata (
kagenti.io/type,app.kubernetes.io/managed-by: kagenti-operator) - Update AgentRuntime status (phase, configuredPods, conditions)
- Resolve
- On delete (finalizer):
- Preserve
kagenti.io/typelabel on PodTemplateSpec - Update
kagenti.io/config-hashto defaults-only hash (triggers rolling update) - Remove finalizer
- Preserve
- Handle missing target workload gracefully (status condition = Error)
- Handle target workload deletion (status condition = TargetNotFound)
- Set up RBAC: get/list/watch/patch on deployments, statefulsets; get/list/watch on configmaps
- Validating webhook for duplicate targetRef rejection (kagenti-operator#242)
3. Config hash computation
Repo: kagenti-operator
Path: kagenti-operator/internal/controller/config_hash.go
Status: Done (kagenti-operator#218, verified in #266)
Tasks:
- Read platform defaults from ConfigMap (
kagenti-webhook-defaultsinkagenti-webhook-systemnamespace) - Merge AgentRuntime spec with defaults (spec fields override defaults)
- Compute SHA256 hash of AgentRuntime spec
- Ensure hash is deterministic (sorted keys, stable serialization)
- When AgentRuntime is deleted, compute hash from defaults only
- Verify: same spec + same defaults = same hash
- Verify: changing any field produces a different hash
- Verify: defaults-only hash differs from spec+defaults hash
4. RBAC and webhook coordination
Repo: kagenti-operator
Path: kagenti-operator/config/rbac/
Status: Done — webhook migrated from kagenti-extensions into kagenti-operator (#261, #249, #245)
Tasks:
- Add RBAC for controller to patch Deployments and StatefulSets (PodTemplateSpec)
- Add RBAC for controller to read ConfigMaps in
kagenti-webhook-system -
Coordinate with kagenti-extensions webhook changesWebhook migrated into operator (#261):- Webhook targets Pods at CREATE time (
objectSelectoronkagenti.io/type) - Webhook reads AgentRuntime CR to merge config at admission time
- Webhook falls back to ConfigMap defaults when no AgentRuntime CR found
- Webhook targets Pods at CREATE time (
- Document controller-webhook interaction (kagenti-operator#290 — sequence diagrams + responsibility split)
- Verify: controller can patch target workloads across namespaces
- Verify: webhook correctly merges config from AgentRuntime CR
- Verify: webhook uses defaults when CR does not exist
5. Unit and integration tests
Repo: kagenti-operator
Path: kagenti-operator/internal/controller/agentruntime_controller_test.go
Status: Unit + envtest done (kagenti-operator#266); E2E done (#270 merged)
Tasks:
- Unit tests: config hash computation
- Deterministic output
- Changes on spec change
- Defaults-only vs spec+defaults
- Unit tests: targetRef resolution
- Deployment target
- StatefulSet target
- Missing target (error path)
- Integration tests (envtest, Ginkgo/Gomega — follow
agentcard_controller_test.gopatterns):- Create AgentRuntime → labels added to target PodTemplateSpec
- Update AgentRuntime → config-hash changes
- Delete AgentRuntime → type label preserved, config-hash updated
- AgentRuntime with missing target → error status
- Target workload deleted after AgentRuntime created → status update
-
make testpasses with all new tests
6. Helm chart updates
Repo: kagenti-operator (charts/) and kagenti (charts/kagenti/)
Status: Done (kagenti-operator#261, kagenti#1153)
Tasks:
- Add AgentRuntime CRD to operator Helm chart
- Add RBAC for new controller permissions in operator chart
- Update kagenti platform chart to generate AgentRuntime CRs for example agents
- Remove
kagenti.io/typelabels from example agent Deployment manifests - Verify:
helm templaterenders correctly - Verify:
helm installdeploys operator with AgentRuntime CRD - Verify: existing AgentCard functionality not affected
7. E2E tests
Repo: kagenti-operator (kagenti-operator/test/e2e/)
Status: Done (kagenti-operator#270 merged, 8 test scenarios, all CI green)
Tasks:
- Test: deploy agent without labels + create AgentRuntime CR → labels appear on PodTemplateSpec
- Test: verify pods get sidecars injected after AgentRuntime creation
- Test: update AgentRuntime → rolling update with new config
- Test: delete AgentRuntime → pods redeployed with platform defaults
- Test: opt-out — add
kagenti.io/inject: disabledto PodTemplateSpec → no injection - All E2E tests pass on Kind cluster
8. Documentation
Repo: kagenti-operator (kagenti-operator/docs/)
Status: Partially done (kagenti-operator#290 merged)
Tasks:
- Update design proposal (PR 📝 Consolidated compositional agent platform design proposal #770) to reflect MVP implementation
- Add AgentRuntime user guide:
- When to create an AgentRuntime CR
- Minimal example (just targetRef + type)
- Full example with identity and trace overrides
- Document Argo CD compatibility:
- Per-Application
ignoreDifferencesconfiguration - Cluster-wide
argocd-cmconfiguration
- Per-Application
- Update install guide with new RBAC requirements
Dependencies
| Dependency | Repo | Status | Notes |
|---|---|---|---|
| Webhook targets Pods at CREATE time | kagenti-operator (migrated from extensions) | Done | kagenti-operator#261; extensions#176 closed |
| Webhook reads AgentRuntime CR for config merging | kagenti-operator (migrated from extensions) | Done | kagenti-operator#245, #261; extensions#177 closed |
| Platform Helm chart generates AgentRuntime CRs | kagenti | Done | kagenti#1153 |
Out of scope
- Layered CRD defaults (
AgentRuntimeClusterConfig/AgentRuntimeConfig) — ConfigMaps sufficient for MVP - xDS config propagation — ConfigMap volume mounts sufficient for MVP
- Sidecar consolidation (4 containers to fewer) — separate effort
design
No response
Goals and non-goals
No response
Success criteria
- Developer deploys a standard Deployment (no kagenti labels) + creates an AgentRuntime CR → sidecars are injected into pods with correct configuration
- kubectl get agentruntime -A shows all enrolled workloads with NAME, TYPE, TARGET, PHASE columns
- Updating an AgentRuntime CR triggers a rolling update and pods receive updated sidecar configuration
- Deleting an AgentRuntime CR preserves the type label and redeploys pods with platform defaults
- Developer can opt out of injection with kagenti.io/inject: disabled
- Webhook targets Pods at CREATE time — Deployment objects in etcd are not mutated by the webhook
- All unit, integration, and E2E tests pass on Kind cluster (kagenti-operator#270 merged, all CI green)
- Demo-ready: full agent lifecycle (create, update, delete AgentRuntime) works end-to-end on Kind
Stories to be associated with this epic
No response
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: add operator alignment guide for Agentic Runtime
docs: add complete deployment inventory to operator alignment
docs: fix operator alignment — AgentRuntime targets Deployments not A…
docs: add DB schema isolation model with naming conventions
pdettori commentedon Apr 16, 2026
Status update (2026-04-15)
Checked off completed items based on merged PRs:
Remaining open items — @varshaprasad96 @cwiklik
The following items are still unchecked. Can you clarify their status or whether they're still needed?
Argo CD compatibility guide (Phase 4 tracker + sub-issue Update for Llama Stack 0.2.3 #8) — Is this still planned? No docs or PRs found for
ignoreDifferencesconfiguration orargocd-cmsetup. Should this be a separate issue?Design proposal update (Final section) — PR 📝 Consolidated compositional agent platform design proposal #770 was merged on 2026-04-13. Does that satisfy "Design proposal updated to reflect implementation", or does 📝 Consolidated compositional agent platform design proposal #770 need a follow-up PR to reflect the final implementation details?
Install guide update with new RBAC requirements (sub-issue Update for Llama Stack 0.2.3 #8) — The RBAC tables were added to
architecture.mdin bug: Weather tool does not start #290. Is a separate install guide update still needed, or does the architecture doc cover it?Once these are resolved, the epic can be closed.