Skip to content

Keep Service ports added by other writers when the operator updates a Service #7068

Open

Description

@jhrozek

When the operator updates the Service of an MCPServer, MCPRemoteProxy or VirtualMCPServer (for example after a session affinity change, or when the auth server TLS listener is turned on), it replaces the whole port list with the ports it generates. Anything another writer put in that list is lost: an appProtocol set on the http port for a Gateway or load balancer, or extra ports such as a metrics port.

Labels and annotations are already merged rather than replaced, because other controllers write to these Services (GKE NEG adds annotations, for example). Ports could follow the same rule. The drift check for Services only looks at the ports the operator owns, so this concerns the update path only.

Proposed behaviour when the operator updates the port list:

  • The operator's own ports (http, and https-auth when the listener is on) come first, in order, built from the desired state.
  • Other ports are kept in their existing order.
  • A kept port is dropped only if it clashes with an operator port, meaning the same number and the same protocol. Kubernetes allows TCP and UDP on the same number, so matching on the number alone is too broad.
  • A kept port with no name is dropped, because a Service with more than one port needs every port named.
  • nodePort is sent as 0 on every port, including the kept ones. An explicit value breaks changing a VirtualMCPServer Service from NodePort to ClusterIP, because the API server rejects a nodePort on a ClusterIP Service. The API server keeps an already allocated NodePort when an update leaves it out.
  • Log at Info level when a port is dropped, so the loss is visible.

A version of this was written while reviewing the "Expose auth server TLS listener port in operator" pull request (#7065). It was taken out to keep that change to one logical change. When this is picked up, it needs envtest cases for an extra port surviving an update, a clash being dropped, and the NodePort to ClusterIP switch.

Activity

  1. added
    needs-triage
    on Nov 6, 2026
  2. removed
    needs-triage
    on Nov 24, 2026
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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions