Skip to content

[BUG] Improve MCPServer Scaling Coordination #4484

Open
1 of 1 issue completed
Open

Description

@olamide226

Scale-to-Zero Leaves Orphaned Backend StatefulSet

Description

When the MCPServer Proxy Deployment is scaled to 0, the backend StatefulSet continues running, resulting in a zombie state with no proxy managing or routing traffic to it.

This happens because the Proxy (proxyrunner) is currently responsible for provisioning and managing the backend StatefulSet. When the Proxy is terminated, no component remains to reconcile or clean up the backend unless the entire MCPServer CR is deleted.

Additionally, the current model implicitly couples Proxy and Backend scaling. In practice, this is suboptimal because the Proxy behaves like a control-plane component, while the backend StatefulSet behaves like a data-plane component. These two should not scale identically.

Environment

  • Operator Version: v0.14.1
  • CRD Version: v0.14.1

Current Behavior

  • Scaling Proxy Deployment to 0 terminates Proxy pods
  • Backend StatefulSet remains running
  • Backend is only cleaned up when the MCPServer CR is deleted
  • Scaling behavior implicitly ties Proxy and Backend replica counts

Expected Behavior

  • Scaling to 0 should result in both:
    • Proxy Deployment scaled to 0
    • Backend StatefulSet scaled to 0
  • Scaling above 1 replica should primarily affect the backend StatefulSet, not the Proxy Deployment
  • Proxy should remain singleton by default (control-plane role)

Current Workaround

  • Scale Proxy to 0 via MCPServer CR
  • Manually scale StatefulSet to 0 using kubectl

Note: This is brittle because proxyrunner uses server-side apply and may overwrite manual scaling on restart.

Proposed Solutions

1. Enable Scale-to-Zero in CRD

Update CRD validation:

  • Change replicas minimum from 1 to 0

2. Decouple Proxy and Backend Scaling

Introduce clear scaling semantics:

  • replicas = 0

    • Proxy = 0
    • Backend = 0
  • replicas = 1

    • Proxy = 1
    • Backend = 1
  • replicas > 1

    • Proxy = 1 (default)
    • Backend = N

Optional:

  • Allow explicit configuration for Proxy replicas for advanced use cases

3. Operator-Coordinated Scaling

Enhance MCPServerReconciler:

  • Handle scaling logic instead of relying solely on proxyrunner
  • Ensure StatefulSet is scaled down when replicas = 0
  • Prevent drift between desired state and actual backend replicas

Note: This may require revisiting ownership boundaries between operator and proxyrunner.

4. Proxy Runner Compatibility

Ensure proxyrunner:

  • Supports replicas = 0
  • Does not override operator-managed scaling
  • Respects decoupled scaling model

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    bug
    on Apr 1, 2026
  2. added
    go
    kubernetes
    on Apr 1, 2026
  3. jerm-dro commented on Apr 2, 2026

    @jerm-dro
    Collaborator

    Hey @olamide226 thanks for filing the issue. Given the current architecture of the proxyrunner, option 2 is not a small amount of work, but I agree it's the idea solution. Today, the proxyrunner is responsible for provisioning the statefulset.

    I'd suggest splitting this issue in two: one for the scale-to-zero work and another for Inflated ReadyReplicas during Rollouts. If you'd like to pick up that readyreplicas work, I'd be happy to review.

  4. changed the title [-][BUG] Improve MCPServer Scaling Coordination and Status Reporting[/-] [+][BUG] Improve MCPServer Scaling Coordination[/+] on Apr 2, 2026
  5. olamide226 commented on Apr 2, 2026

    @olamide226
    ContributorAuthor

    Hey, thanks for the quick feedback and direction.

    That makes sense on option 2 being non-trivial given proxyrunner currently owns the StatefulSet lifecycle.

    I’ve split this into two focused issues:
    • Scale-to-zero behavior and backend orphaning.(this ticket)
    • Inflated ReadyReplicas during rollouts. #4498

    I’ll be happy to pickup the ReadyReplicas issue and put together a PR for that since it looks fairly contained within the status reconciliation logic.

    For the scale-to-zero path, happy to align on direction before attempting anything given the architectural implications around proxyrunner.

    Let me know if there are any preferences on how you’d like the status fix implemented.

  6. jerm-dro commented on Apr 2, 2026

    @jerm-dro
    Collaborator

    @olamide226 I've assigned you #4498. Thank you for volunteering! I'd be happy to review once that's ready.

    On the scale-to-zero topic, let me chat with the rest of the team on the best path forward here. I'll get back to you.

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

    buggokubernetes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions