Skip to content

Conversation

@peninoule
Copy link
Contributor

@peninoule peninoule commented Nov 21, 2025

Description

This PR adds support for the PriorityClassName attribute for the gateway proxy pods.

Right now pods are created with the default PriotityClass. It can be an issue in environments with very volatile workloads (like AWS spots instances) where teams rely on the PriorityClassName to ensure critical pieces of the cluster remain active.
With the default PriorityClass, gateway proxy pods are under threat of preemption.

Change Type

/kind feature

Changelog

Adds `priorityClassName` to the Pod struct used in GatewayParameters in order to set the corresponding [priorityClassName](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) field in the gateway-proxy pod.

Additional Notes

closes: #11917

@gateway-bot gateway-bot added do-not-merge/description-invalid do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 21, 2025
@peninoule peninoule force-pushed the feat/add-priority-class-name branch from 6301746 to 7dc3005 Compare November 21, 2025 15:28
@gateway-bot gateway-bot added release-note kind/feature Categorizes issue or PR as related to a new feature. and removed do-not-merge/description-invalid do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/kind-invalid Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 24, 2025
@peninoule peninoule force-pushed the feat/add-priority-class-name branch from 7dc3005 to 89b5dcf Compare November 24, 2025 08:54
@peninoule peninoule marked this pull request as ready for review November 24, 2025 08:55
Copilot AI review requested due to automatic review settings November 24, 2025 08:55
Copy link
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 adds support for the PriorityClassName field to gateway proxy pods to prevent pod preemption in environments with volatile workloads. The implementation follows the established pattern for adding Pod template configuration fields.

Key changes:

  • Added PriorityClassName *string field to the Pod struct with getter method
  • Updated merge logic, deployer values, and Helm templates to propagate the field
  • Added CRD schema definition and test coverage

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/v1alpha1/kube_types.go Adds PriorityClassName field and GetPriorityClassName() method to Pod struct
pkg/deployer/values.go Adds PriorityClassName field to HelmGateway struct
pkg/deployer/merge.go Adds merge logic for PriorityClassName using MergePointers helper
internal/kgateway/deployer/gateway_parameters.go Propagates PriorityClassName value from PodTemplate to gateway configuration
internal/kgateway/helm/envoy/templates/deployment.yaml Adds conditional rendering of priorityClassName in deployment spec
install/helm/kgateway-crds/templates/gateway.kgateway.dev_gatewayparameters.yaml Adds priorityClassName to CRD schema
pkg/deployer/deployer_test.go Adds test data and assertion for PriorityClassName field

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

@peninoule peninoule marked this pull request as draft November 24, 2025 09:51
@peninoule peninoule marked this pull request as ready for review November 24, 2025 10:27
@peninoule peninoule force-pushed the feat/add-priority-class-name branch from 3378092 to 8ad63fc Compare November 24, 2025 15:52
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $gateway.priorityClassName }}
priorityClassName: {{ $gateway.priorityClassName }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's protect against a user who names a PriorityClass a YAML reserved word with priorityClassName: {{ $gateway.priorityClassName | quote }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in : 9d38407

},
},
PodTemplate: &gw2_v1alpha1.Pod{
PriorityClassName: ptr.To("default"),
Copy link
Contributor

Choose a reason for hiding this comment

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

The only default PCs are system-cluster-critical and system-node-critical. The default PC is really to omit the PC, so why add this? (If someone uses globalDefault in a PC, then presumably they would not use the setting you're adding in this PR.)

Instead, chandler-solo@112764e tests this as end-to-end as is necessary. Please cherry pick it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cherry-picked 👍 Thank you for that 🙇‍♂️

dst.LivenessProbe = deepMergeProbe(dst.GetLivenessProbe(), src.GetLivenessProbe())
dst.TopologySpreadConstraints = DeepMergeSlices(dst.GetTopologySpreadConstraints(), src.GetTopologySpreadConstraints())
dst.ExtraVolumes = DeepMergeSlices(dst.GetExtraVolumes(), src.GetExtraVolumes())
dst.PriorityClassName = MergePointers(dst.PriorityClassName, src.PriorityClassName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Elsewhere we use MergeComparable for some (all?) *string, but that's semantically nonsensical and MergePointers is correct. (I put up #12978 to clean this up.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I leave it as it is then 👍

@peninoule peninoule force-pushed the feat/add-priority-class-name branch 2 times, most recently from 9d38407 to 1592b47 Compare November 26, 2025 09:29
Copy link
Contributor

@chandler-solo chandler-solo left a comment

Choose a reason for hiding this comment

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

We'll need a maintainer to get CI checks running and approve.

peninoule and others added 5 commits December 1, 2025 14:03
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
@peninoule peninoule force-pushed the feat/add-priority-class-name branch from 1592b47 to 8b9d561 Compare December 1, 2025 13:53
@peninoule
Copy link
Contributor Author

We'll need a maintainer to get CI checks running and approve.

Sorry I disappeared. Tests should succeed now

@lgadban lgadban added this pull request to the merge queue Dec 1, 2025
Merged via the queue into kgateway-dev:main with commit 2034334 Dec 1, 2025
30 checks passed
@moi34500
Copy link

moi34500 commented Dec 1, 2025

Let’s goooooo

@peninoule
Copy link
Contributor Author

Thanks for the help, the review and the merge ! Cheers.

@peninoule peninoule deleted the feat/add-priority-class-name branch December 2, 2025 08:08
sheidkamp pushed a commit to sheidkamp/kgateway that referenced this pull request Dec 3, 2025
Signed-off-by: Pierre-Jean CROUZET <[email protected]>
Signed-off-by: David L. Chandler <[email protected]>
Co-authored-by: David L. Chandler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support TopologySpreadConstraints in gateway parameters

6 participants