Skip to content

TrafficPolicy urlRewrite.pathRegex field missing in v2.1.2 CRD but documented #13452

@runitmisra

Description

@runitmisra

kgateway version

v2.1.2

Kubernetes Version

v1.33

Describe the bug

Environment

  • kgateway Version: v2.1.2
  • Kubernetes Version: 1.33
  • Platform: AWS EKS
  • Installation Method: Helm

Description

The kgateway documentation shows TrafficPolicy with a urlRewrite.pathRegex field for regex-based URL path rewriting, but this field does not exist in the actual v2.1.2 CRD and is rejected by the API server.

Attempting to create this TrafficPolicy results in an API error:

Error from server (BadRequest): error when creating "STDIN": TrafficPolicy in version "v1alpha1" cannot be handled as a TrafficPolicy: strict decoding error: unknown field "spec.urlRewrite"

CRD Investigation

Available fields in TrafficPolicy v2.1.2:

$ kubectl explain trafficpolicy.spec --api-version=gateway.kgateway.dev/v1alpha1

Output:

  • ai
  • autoHostRewrite
  • buffer
  • cors
  • csrf
  • extAuth
  • extProc
  • headerModifiers
  • rateLimit
  • rbac
  • retry
  • targetRefs
  • targetSelectors
  • timeouts
  • transformation

The urlRewrite field is NOT present.

Questions

  1. Is urlRewrite.pathRegex planned for a future version? If so, which version?
  2. Is the documentation incorrect or ahead of the actual release?
  3. What is the recommended approach for regex-based URL rewriting in v2.1.2?
  4. Is there a migration path from ingress-nginx annotations like rewrite-target: /$2 with regex patterns?

Expected Behavior

Expected Behavior (According to Documentation)

Documentation source: https://kgateway.dev/docs/envoy/latest/traffic-management/rewrite/path/#regex-rewrite

The TrafficPolicy CRD should support regex-based URL rewriting with capture groups:

apiVersion: gateway.kgateway.dev/v1alpha1
kind: TrafficPolicy
metadata:
  name: url-rewrite-policy
  namespace: default
spec:
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: api-route
  urlRewrite:
    pathRegex:
      pattern: "^/api/v1/users/([0-9]+)/posts/([0-9]+)$"
      substitution: "/internal/user/\\1/post/\\2"

Steps to reproduce the bug

Reproduction Steps

  1. Install kgateway v2.1.2
  2. Create an HTTPRoute
  3. Attempt to create a TrafficPolicy with urlRewrite.pathRegex:
apiVersion: gateway.kgateway.dev/v1alpha1
kind: TrafficPolicy
metadata:
  name: test-rewrite
  namespace: gateway-poc-test
spec:
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: test-route
  urlRewrite:
    pathRegex:
      pattern: "^/old/(.*)$"
      substitution: "/new/\\1"
  1. Observe API rejection error

Additional Environment Detail

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions