Skip to content

GEP-1619: Add Session Persistence API to Backend - #5298

Merged
kubernetes-prow[bot] merged 4 commits into
kubernetes-sigs:mainfrom
gcs278:backend-session-persistence-api
Sep 28, 2026
Merged

kubernetes-prow[bot] merged 4 commits into
kubernetes-sigs:mainfrom
gcs278:backend-session-persistence-api

Conversation

@gcs278

@gcs278 gcs278 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind gep

What this PR does / why we need it:
Implement Session Persistence API as described in #4876 in xBackend's spec.endpointSelector field.

Also, update GEP-4894 to reflect Session Persistence is no longer future item.

Which issue(s) this PR fixes:
Fixes # N/A

Related #4462 #4258

Does this PR introduce a user-facing change?:

Add session persistence API to xBackend.

Was AI used in preparing this PR?
/label ail/2

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/gep PRs related to Gateway Enhancement Proposal(GEP) ail/2 Categorizes a PR as having AI Influence Level 2 (major AI augmentation) needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 24, 2026
@kubernetes-prow

Copy link
Copy Markdown

This issue is currently awaiting triage.

If Gateway API community members determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Sep 24, 2026
@gcs278

gcs278 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@rikatz @youngnick Ready for review - this is the implementation of #4876 which just merged with some mild GEP-4894 updates to reflect that. Hopefully a quick review.

CC: @mikemorris @keithmattix FYI

@gcs278

gcs278 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

CC: @snorwin you may be interested too

@snorwin

snorwin commented Sep 24, 2026

Copy link
Copy Markdown
Member

/cc

@kubernetes-prow
kubernetes-prow Bot requested a review from snorwin September 24, 2026 17:21
@rikatz

rikatz commented Sep 25, 2026

Copy link
Copy Markdown
Member

/lgtm

leaving approval for @robscott or @youngnick

thanks!

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 25, 2026
Comment thread apisx/v1alpha1/xbackend_types.go Outdated
// Support: Extended
//
// +optional
SessionPersistence *SessionPersistence `json:"sessionPersistence,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@gcs278 maybe I missed the discussion, but why do we only want session persistence for in-cluster and not for external backends?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

because you can't know what is your backend when you are on external hostnames.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yea please correct if I'm missing something, but there is no explicit list of endpoints to be selected in the external hostname egress case.

Can there load balancing with egress? Sort of - I suppose a DNS record could have multiple IPs, which a gateway can potentially load balance to - however, that session persistence (e.g. like a cookie) should be established by the external egress service.

In egress, the local gateway is acting as the "client" - it feels like it's not the correct layer to initiate session persistence. It's equivalent to saying a browser should perform endpoint-level selection. Hence the limitation to in-cluster.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On a somewhat related note, I think I'd prefer to have this be top level on the backend type and instead rely on CEL validation to determine what types of backend this is applicable to. It seems possible that in the future we may add other ways to refer to backends in a cluster, such as an objectRef, and moving this to the top level now would avoid the need for repeating it in multiple locations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@gcs278 I had exactly that case in mind, a transparent DNS where the client gets all endpoint IPs of a backend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm that's fair. I'll move it up a level to be safe for future use cases.

It seems possible that in the future we may add other ways to refer to backends in a cluster, such as an objectRef

I suppose if you are saying that backend may refer to more than just endpointSelectors in the future - that's fair.

Pushed changes in the latest commit 51faf9d.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops sorry I found a bug that I previously introduced in backend, I have also fixed that in a separate commit. The +required marker on a inline field is causing failures requiring an empty string. Fixed in another commit.

@robscott robscott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @gcs278! One small nit around the placement of this field, but otherwise LGTM.

@gcs278
gcs278 force-pushed the backend-session-persistence-api branch from 7142379 to cbe2739 Compare September 28, 2026 16:23
@kubernetes-prow kubernetes-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 28, 2026
@gcs278
gcs278 force-pushed the backend-session-persistence-api branch 2 times, most recently from 51faf9d to bffc347 Compare September 28, 2026 16:33
@gcs278

gcs278 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@robscott @snorwin ready for another review - I found a bug in backend endpointSelector that I fixed in this PR in a separate commit out of simplicity, but I'm also happy to split that off if you'd rather have it organized as a separate PR.

Comment thread apisx/v1alpha1/xbackend_types.go Resolved
@gcs278
gcs278 force-pushed the backend-session-persistence-api branch from 3a5a3d5 to 698b82c Compare September 28, 2026 21:27
Implement Session Persistence API as described in kubernetes-sigs#4876 in Backend
spec.endpointSelector. Update GEP-4894 to reflect Session Persistence is
no longer future item.
Refactor SessionPersistence API to move to the top level of backend so
that it can potentially be re-used with other object references of
backend in the future. Use CEL to restrict it to EndpointSelector for
now.
@gcs278
gcs278 force-pushed the backend-session-persistence-api branch from 698b82c to 98a84a3 Compare September 28, 2026 21:33
The spec.endpointSelector.labelSelector field was inlined and has no
JSON property name which causes all objects to fail with invalid
required: [""] error. The matchLabel field within labelSelector is
already required, while the inlined struct should be optional.
@gcs278
gcs278 force-pushed the backend-session-persistence-api branch from 98a84a3 to 1ceb033 Compare September 28, 2026 21:35

@robscott robscott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @gcs278! Just a few small nits, otherwise LGTM.

Comment thread apisx/v1alpha1/xbackend_types.go Resolved
Comment thread geps/gep-4894/index.md Resolved
Comment thread apisx/v1alpha1/xbackend_types.go Resolved
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gcs278, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 28, 2026
- Update CEL to use ternary and CEL message
- Fix double negative of API doc
- Remove session persistence from GEP-4894
@robscott

Copy link
Copy Markdown
Member

Thanks @gcs278!

/lgtm
/hold cancel

@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 28, 2026
@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 28, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit d15a5c5 into kubernetes-sigs:main Sep 28, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ail/2 Categorizes a PR as having AI Influence Level 2 (major AI augmentation) approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/gep PRs related to Gateway Enhancement Proposal(GEP) lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants