Skip to content

feat: add gcp affinity annotation parsing#343

Closed
chakravardhan wants to merge 2 commits intokubernetes-sigs:mainfrom
chakravardhan:feature/gcp-affinity-annotations
Closed

feat: add gcp affinity annotation parsing#343
chakravardhan wants to merge 2 commits intokubernetes-sigs:mainfrom
chakravardhan:feature/gcp-affinity-annotations

Conversation

@chakravardhan
Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:

This PR introduces support for parsing Nginx Ingress session affinity annotations and translating them to GKE Gateway API resources.
Specifically, this PR:

  • Adds parsing for nginx.ingress.kubernetes.io/affinity and nginx.ingress.kubernetes.io/session-cookie-max-age in the ingress-nginx provider.
  • Automatically generates a GCPBackendPolicy with SessionAffinityConfig set to GENERATED_COOKIE when affinity: "cookie" is detected and the tool is run with --emitters=gce.
  • Maps session-cookie-max-age to CookieTTLSec with strict bound-checking [0, 1209600] (14 days) to align with GCP's API constraints, surfacing validation errors early for invalid configurations.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

Added support for translating Nginx Ingress annotations `affinity: "cookie"` and `session-cookie-max-age` into `GCPBackendPolicy` SessionAffinityConfigs when using the `gce` emitter.

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 10, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chakravardhan
Once this PR has been reviewed and has the lgtm label, please assign stevenjin8 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 10, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @chakravardhan. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 10, 2026
@chakravardhan chakravardhan changed the title feat(provider/nginx): add gcp affinity annotation parsing feat: add gcp affinity annotation parsing Feb 10, 2026
// affinityFeature parses the ingress-nginx affinity annotations and populates
// the ProviderSpecificServiceIR.Gce.SessionAffinity.
func affinityFeature(_ []networkingv1.Ingress, _ map[types.NamespacedName]map[string]int32, ir *providerir.ProviderIR) field.ErrorList {
var errs field.ErrorList
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I might havesaid this in another PR, but can we avoid using the ProviderSpecificServiceIR? Its only there for backcompat reasons. For example, what if another emitter also wants to implement sessionaffinity? Would they have to read ProviderSpecificServiceIR.Gce?

Copy link
Copy Markdown
Contributor Author

@chakravardhan chakravardhan Feb 19, 2026

Choose a reason for hiding this comment

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

Agreed @Stevenjin8, Should we move the SessionAffinity outside ProviderSpecificServiceIR into a common ServiceContext variable? wdyt?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2026
@chakravardhan chakravardhan force-pushed the feature/gcp-affinity-annotations branch from b25dd60 to 31d25fb Compare February 19, 2026 12:34
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 19, 2026
@chakravardhan chakravardhan force-pushed the feature/gcp-affinity-annotations branch from 31d25fb to 7233168 Compare February 19, 2026 12:39
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 19, 2026
@Stevenjin8
Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 19, 2026
// has a dedicated field for each provider to specify their extension features
// on Service.
type ServiceContext struct {
ProviderSpecificIR ProviderSpecificServiceIR
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we avoid having provider specific fields in the IR. The whole point is that it isn't provider specific

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 25, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@chakravardhan: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-ingress2gateway-e2e 7233168 link true /test pull-ingress2gateway-e2e

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Copy link
Copy Markdown

@DamianSawicki DamianSawicki left a comment

Choose a reason for hiding this comment

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

  1. Thanks for taking care of it! Since 1.0 is now official, it would be great to get this merged asap.
  2. It may be outside the scope of this particular PR, but nginx.ingress.kubernetes.io/session-cookie-name can be translated with GCP HTTP_COOKIE session affinity type instead of GENERATED_COOKIE. It requires using GCPTrafficDistributionPolicy instead of GCPBackendPolicy to configure session affinity (https://docs.cloud.google.com/kubernetes-engine/docs/how-to/configure-gateway-resources#expanded-session-affinity).

@DamianSawicki
Copy link
Copy Markdown

Thanks for taking care of it! Since 1.0 is now official, it would be great to get this merged asap.

Actually, is this still relevant or was it superseded by #394?

@chakravardhan
Copy link
Copy Markdown
Contributor Author

Thanks for taking care of it! Since 1.0 is now official, it would be great to get this merged asap.

Actually, is this still relevant or was it superseded by #394?

Yes, the current PR is superseded by #394. Its not relevant anymore unless we pivot the PR to produce GCPTrafficDistributionPolicy. I'll close this PR for now.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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