Skip to content

Reduce controller-runtime surface #3235

Open
Open

Description

@timflannagan

Problem

Kagent still exposes controller-runtime clients and caches to application logic, creating overlapping access patterns and coupling reconciliation to manager internals.

Types read through both KRT and the manager client (Secrets, ConfigMaps, AgentTemplates, RemoteMCPServers, ...) are watched twice, and the two caches can disagree.

Direction

Align Kubernetes access with the kgateway apiclient pattern:

  • Own an Istio kube.Client and generated clientsets behind the shared API client.
  • Use KRT/kclient for cached, watch-driven reads.
  • Use generated typed clients for request-scoped CRUD.
  • Limit controller-runtime to manager lifecycle, leader election, and integrations that require it.

Completion criteria

  • Migrate affected controllers, including RemoteMCP reconciliation.
  • Remove direct GetClient()/GetCache() use and guard against regressions.
  • Add focused reconciliation coverage and document cache ownership.

References:

Activity

  1. changed the title [-]Epic: Reduce controller-runtime Kubernetes access in favor of Istio kube client and KRT[/-] [+]Reduce controller-runtime Kubernetes access in favor of Istio kube client and KRT[/+] on Oct 16, 2026
  2. changed the title [-]Reduce controller-runtime Kubernetes access in favor of Istio kube client and KRT[/-] [+]Reduce controller-runtime surface[/+] on Oct 16, 2026
  3. Vaibhaav-Tiwari commented on Oct 20, 2026

    @Vaibhaav-Tiwari

    Hi @timflannagan, I'd like to help with this if you're open to splitting it up.

    I mapped the current state on main (2261632). go/core/pkg/app/app.go passes manager.GetClient() straight to 12 services (models, tools, prompts, system, schedules, sandboxes, and the kubecrud services for Agent, AgentTemplate, Harness and SandboxTemplate), plus the RemoteMCP discovery controller. 18 non-test files import controller-runtime's client or cache package.

    Following the kgateway commit, I'd propose doing it in stages:

    1. Migrate the RemoteMCP reconciler to KRT/kclient for cached reads, with focused reconciliation tests.
    2. Move the kubecrud services to generated typed clients behind the shared API client.
    3. Move the remaining services, then add a lint/test guard against new GetClient()/GetCache() calls and document cache ownership.

    Would you like me to take this up? or are you already working on this?

    Image
  4. timflannagan commented on Nov 9, 2026

    @timflannagan
    ContributorAuthor

    @Vaibhaav-Tiwari Apologies - sissed this notification. Agreed with the proposed stages here, but I think we'll want a maintainer to tackle this since there's more to unwind. I'll likely tackle most of this when I get background cycles

  5. Vaibhaav-Tiwari commented on Nov 9, 2026

    @Vaibhaav-Tiwari

    @Vaibhaav-Tiwari Apologies - sissed this notification. Agreed with the proposed stages here, but I think we'll want a maintainer to tackle this since there's more to unwind. I'll likely tackle most of this when I get background cycles

    No worries, thanks! makes sense. If a smaller piece of this comes up that you'd like to hand off, I'm happy to take it

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions