Skip to content

feat(labels): add gateway.selectorLabels with component label#171

Open
camjay wants to merge 2 commits intoPortkey-AI:mainfrom
camjay:feat/gateway-selector-labels
Open

feat(labels): add gateway.selectorLabels with component label#171
camjay wants to merge 2 commits intoPortkey-AI:mainfrom
camjay:feat/gateway-selector-labels

Conversation

@camjay
Copy link
Copy Markdown

@camjay camjay commented Mar 24, 2026

⚠️ Upgrade note: This changes the gateway Service selector. See "Upgrade impact" below before merging.

Adds a gateway.selectorLabels helper with app.kubernetes.io/component: gateway, matching the existing dataservice.selectorLabels pattern. Applied to pod labels and Service selectors (both mutable).

Deployment matchLabels left unchanged to avoid requiring Deployment recreation. Users who want the component label in matchLabels can opt in via .Values.selectorLabels.

Upgrade impact

The gateway Service selector gains app.kubernetes.io/component: gateway. Old pods (from the previous chart version) don't have this label in their metadata. During a rolling update:

  1. New Service selector requires component: gateway
  2. Old pods lack this label → Service stops routing to them
  3. New pods aren't ready yet → brief traffic interruption

Mitigations:

  • Set strategy.rollingUpdate.maxSurge: 100% so new pods start before old ones terminate
  • Or do a blue-green deploy: scale up new pods, verify health, then scale down old

Subsequent upgrades are unaffected — all pods will have the label.

This trade-off mirrors what already happened with dataservice.selectorLabels, which includes app.kubernetes.io/component in both Service selectors and Deployment matchLabels. The gateway version is intentionally less disruptive (Service only, not matchLabels).

See also #173 which adds CI to validate chart templates on PRs.

Add gateway.selectorLabels helper with app.kubernetes.io/component:
gateway, matching the existing dataservice.selectorLabels pattern.
Applied to pod labels and Service selectors (both mutable).

Deployment matchLabels left unchanged to avoid requiring recreation.
Users who want it in matchLabels can use .Values.selectorLabels.

Note: the Service selector now includes component: gateway. During
upgrade from a previous version, old pods lack this label and won't
receive traffic until new pods are ready. Use maxSurge: 100% or
blue-green deploy to avoid downtime on first upgrade.
@camjay camjay force-pushed the feat/gateway-selector-labels branch from a1f053a to 97a1c71 Compare March 24, 2026 22:05
@camjay camjay marked this pull request as ready for review March 25, 2026 01:08
@sk-portkey sk-portkey requested a review from Copilot March 25, 2026 09:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the portkey-gateway Helm chart labeling helpers so the gateway Service selector (and gateway pod labels) include app.kubernetes.io/component: gateway, aligning with the existing dataservice selector-label pattern while avoiding changes to the Deployment’s immutable matchLabels.

Changes:

  • Add a new gateway.selectorLabels helper that composes portkeyenterprise.selectorLabels and a fixed app.kubernetes.io/component: gateway label.
  • Update gateway Services to use gateway.selectorLabels instead of portkeyenterprise.selectorLabels.
  • Update gateway.labels to include gateway.selectorLabels so gateway pods receive the new component label.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
charts/portkey-gateway/templates/gateway/service.yaml Switch Service selectors (including MCP Service) to gateway.selectorLabels so Services select gateway pods via the component label.
charts/portkey-gateway/templates/_helpers.tpl Introduce gateway.selectorLabels and wire it into gateway.labels so pod labels match the updated Service selectors.

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sk-portkey
Copy link
Copy Markdown
Contributor

@camjay

Thanks for the PR and the thorough write-up on upgrade impact — it's clear you've thought this through carefully.

That said, I'm going to hold off on merging this as-is. The core concern is that this changes the Service selector for all existing installs, which means every upgrade hits a traffic interruption regardless of whether the user needs the tighter selector. The mitigations (maxSurge, blue-green) put the burden on operators to work around a change they didn't ask for.

The existing .Values.selectorLabels hook already lets users add app.kubernetes.io/component: gateway today if they need selector precision — no chart change required.

If there's appetite for a more ergonomic path, I'd be open to a PR that adds a gateway.deployment.selectorLabels values key (mirroring what dataservice does), but defaulting to empty so existing installs are unaffected. That way users can opt in when they're ready rather than having it forced on upgrade.

Appreciate the contribution — happy to discuss if you see a use case that .Values.selectorLabels doesn't cover.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants