Skip to content

trafficpolicy: hash polices for hashing load balancers #11583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

puertomontt
Copy link
Contributor

@puertomontt puertomontt commented Jul 3, 2025

Description

#11457
In order to support hashing load balancers (ring hash and maglev) in BackendConfigPolicy, it is necessary to define the hash policy on the route.

This PR adds options on the TrafficPolicy to configure hash policy on a route. Currently only HTTPRoute as targetRef is supported (Gateway is not supported).

Change Type

/kind new_feature

Changelog

add hash policy to TrafficPolicy for configuring hashing loadbalancers

Additional Notes

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 14:22
@github-actions github-actions bot added 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 Jul 3, 2025
Copy link
Contributor

@Copilot 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 defining and applying HTTP route-level hash policies (for RingHash and Maglev load balancers) via the TrafficPolicy API, wiring them through the CRD, apply-configuration, translator plugins, and integration tests.

  • Introduce HashPolicies in the TrafficPolicy CRD and apply-configuration types
  • Implement hashPolicyForSpec to translate CRD hash policies into Envoy RouteAction_HashPolicy IR and wire it in the translator and merge logic
  • Update test utilities and add unit/integration tests for route-level hash policy translation

Reviewed Changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
api/v1alpha1/traffic_policy_types.go Add HashPolicies field to TrafficPolicySpec
api/applyconfiguration/api/v1alpha1/trafficpolicyspec.go Extend apply-configuration to include HashPolicies
api/applyconfiguration/utils.go Register apply-configuration kinds for Cookie, Header, HashPolicy, SourceIP
internal/kgateway/extensions2/plugins/trafficpolicy/hash_policy.go Implement hashPolicyForSpec to build Envoy hash IR
internal/kgateway/extensions2/plugins/trafficpolicy/traffic_policy_plugin.go Wire hash policies into route generation and merging
internal/kgateway/extensions2/plugins/trafficpolicy/builder.go Invoke hashPolicyForSpec in the builder
internal/kgateway/translator/gateway/testutils/inputs/loadbalancer/route.yaml Add sample input for route-level hash policies
internal/kgateway/translator/gateway/testutils/outputs/loadbalancer/route.yaml Add expected Envoy config with hash policies
internal/kgateway/translator/gateway/gateway_translator_test.go Add integration test entry for route-level hash policy
internal/kgateway/extensions2/plugins/trafficpolicy/hash_policy_test.go Unit tests for hashPolicyForSpec
install/helm/kgateway-crds/templates/gateway.kgateway.dev_trafficpolicies.yaml Extend CRD schema for hash policies

@github-actions github-actions bot added kind/feature Categorizes issue or PR as related to a new feature. release-note and removed 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 Jul 3, 2025
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.

1 participant