Skip to content

Support dynamic Host header rewrite with sourceHeader in ListenerRuleConfiguration CRD#4697

Open
yaswanthkumar1995 wants to merge 1 commit into
kubernetes-sigs:mainfrom
yaswanthkumar1995:feature/dynamic-host-header-rewrite
Open

Support dynamic Host header rewrite with sourceHeader in ListenerRuleConfiguration CRD#4697
yaswanthkumar1995 wants to merge 1 commit into
kubernetes-sigs:mainfrom
yaswanthkumar1995:feature/dynamic-host-header-rewrite

Conversation

@yaswanthkumar1995
Copy link
Copy Markdown

Issue

#4693

Description

Adds support for specifying host-header-rewrite transforms directly through the ListenerRuleConfiguration CRD, enabling multi-tenant SaaS patterns where the Host header needs to be dynamically rewritten using the value of another incoming request header (e.g., X-School-Domain).

This implements Option A from the issue — a new transforms field in the ListenerRuleConfiguration CRD with a sourceHeader reference:

apiVersion: gateway.k8s.aws/v1beta1
kind: ListenerRuleConfiguration
metadata:
  name: tenant-host-rewrite
spec:
  transforms:
    - type: host-header-rewrite
      hostHeaderRewriteConfig:
        sourceHeader: X-School-Domain
        rewrites:
          - regex: ".*"
            replace: "$0"

What changed:

File Change
apis/gateway/v1beta1/listenerruleconfig_types.go Add Transforms field to ListenerRuleConfigurationSpec with host-header-rewrite type, sourceHeader, and kubebuilder validation markers
pkg/model/elbv2/listener_rule.go Add SourceHeader field to RewriteConfigObject internal model
pkg/gateway/routeutils/route_rule_transform.go Add BuildListenerRuleConfigTransforms() to convert CRD transforms to internal model
pkg/gateway/model/model_build_listener.go Add mergeTransforms() — merges route-level and CRD-level transforms, CRD takes precedence for same-type overrides

Design decisions:

  • sourceHeader is a forward-looking field. AWS ALB does not yet natively support cross-header references (confirmed by AWS Premium Support). The field is wired through the CRD and internal model so that when AWS adds SDK support, only the SDK builder (buildSDKHostHeaderRewriteConfig) needs updating.
  • CRD transforms override route-generated transforms of the same type (e.g., a CRD host-header-rewrite replaces one generated from HTTPRoute hostname matching).
  • Scoped to host-header-rewrite only — no url-rewrite in the CRD since it wasn't requested.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 19, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: yaswanthkumar1995 / name: Yaswanth Kumar (661507d)

@k8s-ci-robot k8s-ci-robot requested a review from wweiwei-li April 19, 2026 18:06
@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Apr 19, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yaswanthkumar1995
Once this PR has been reviewed and has the lgtm label, please assign zac-nixon 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 requested a review from zac-nixon April 19, 2026 18:06
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @yaswanthkumar1995!

It looks like this is your first PR to kubernetes-sigs/aws-load-balancer-controller 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-load-balancer-controller has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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 Apr 19, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @yaswanthkumar1995. 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 19, 2026
…Configuration CRD

Adds support for specifying host-header-rewrite transforms directly through
the ListenerRuleConfiguration CRD, enabling multi-tenant SaaS patterns where
the Host header needs to be dynamically rewritten using the value of another
incoming request header (e.g., X-School-Domain).

Changes:
- Add Transforms field to ListenerRuleConfigurationSpec with support for
  host-header-rewrite transform type
- Add SourceHeader field to host-header-rewrite config for cross-header
  reference (forward-looking for when AWS ALB adds native support)
- Add BuildListenerRuleConfigTransforms to convert CRD transforms to
  internal model transforms
- Add mergeTransforms to merge route-level and CRD-level transforms,
  with CRD transforms taking precedence for same-type overrides
- Add unit tests for new functionality

Ref: kubernetes-sigs#4693
@yaswanthkumar1995 yaswanthkumar1995 force-pushed the feature/dynamic-host-header-rewrite branch from 66310a0 to 661507d Compare April 19, 2026 18:07
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 19, 2026
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. needs-ok-to-test Indicates a PR that requires an org member to verify it 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.

2 participants