Skip to content

feat: add optional name to httproute rules#407

Merged
pierluigilenoci merged 3 commits into
oauth2-proxy:mainfrom
tboerger:feat/gateway-rule-name
May 22, 2026
Merged

feat: add optional name to httproute rules#407
pierluigilenoci merged 3 commits into
oauth2-proxy:mainfrom
tboerger:feat/gateway-rule-name

Conversation

@tboerger
Copy link
Copy Markdown
Contributor

Description

In order to apply security policies from gateway api implementations like Envoy Gateway to the HTTPRoute I have added an optional name attribute to the rules. These name attributes can be matched by the sectionName of other resources.

As an example this can't match without a named rule to specific rules:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
  name: example
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: oauth2-proxy
      sectionName: service

Checklist:

  • I have bumped the version in the Chart.yaml according to Semantic Versioning.
  • I have updated the documentation/CHANGELOG at the bottom of the Chart.yaml
  • I have signed off all my commits.
  • (Optional) I have updated the Chart.lock for dependency updates
  • (Optional) I have implemented helm tests for new feature flags

@tboerger tboerger force-pushed the feat/gateway-rule-name branch 2 times, most recently from b8c794b to ab4af24 Compare May 10, 2026 22:36
@pierluigilenoci
Copy link
Copy Markdown
Member

Hi @tboerger, thanks for this PR! The use case makes sense — being able to target specific HTTPRoute rules with SecurityPolicy via sectionName is a valid need.

CI is green ✅ (both DCO and lint-test pass). A few suggestions/requests before merging:

1. Field positioning in the template

Per the Gateway API spec, name is a top-level field of HTTPRouteRule (same level as matches, backendRefs, filters). For readability and consistency with the spec ordering, it would be better placed before matches:

  {{- range .Values.gatewayApi.rules }}
- - matches:
+  - {{- if .name }}
+    name: {{ .name }}
+    {{- end }}
+    matches:

(or at minimum before filters, not after it)

2. Version bump conflict

You bumped to 10.5.0, which conflicts with PR #400 (also at 10.5.0). Depending on merge order, one will need a rebase. Since this is a feature addition (minor bump is correct), the number will need to be reconciled after the first one lands. Just a heads-up — we'll sort it out at merge time.

3. Add a CI test value file

There's no chart-testing scenario covering the name field for HTTPRoute rules. Adding one would prevent regressions:

# ci/httproute-name-values.yaml
gatewayApi:
  enabled: true
  gatewayRef:
    name: test-gateway
  rules:
    - name: service
      matches:
        - path:
            type: PathPrefix
            value: /
    - name: metrics
      matches:
        - path:
            type: PathPrefix
            value: /metrics

4. Document the new field in values.yaml

The rules section in values.yaml shows an example but doesn't mention the optional name field. A brief comment would help discoverability:

  # HTTPRoute rule configuration
  # rules:
  # - name: service        # optional: enables targeting by sectionName in policies
  #   matches:
  #   - path:
  #       type: PathPrefix
  #       value: /

Let me know if you have questions — happy to help!

Copy link
Copy Markdown
Contributor

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 extends the Helm chart’s Gateway API support by allowing each generated HTTPRoute rule to optionally set a name, enabling external policy resources (e.g., Envoy Gateway SecurityPolicy) to target specific rules via sectionName.

Changes:

  • Add optional name rendering for each gatewayApi.rules[] entry in the HTTPRoute template.
  • Bump chart version to 10.5.0.
  • Update the Artifact Hub changelog entry to describe the new capability and link to the PR.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
helm/oauth2-proxy/templates/httproute.yaml Adds optional rule-level name field rendering for HTTPRoute rules.
helm/oauth2-proxy/Chart.yaml Bumps chart version and updates Artifact Hub changelog entry/link.
Comments suppressed due to low confidence (1)

helm/oauth2-proxy/templates/httproute.yaml:54

  • This introduces a new user-facing value (gatewayApi.rules[].name), but it isn't currently documented in the chart values examples/README (only matches/filters are shown). Please add it to the documented Gateway API rules examples so users can discover how to set it for PolicyAttachment sectionName use-cases.
    {{- if .name }}
    name: {{ .name }}
    {{- end }}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread helm/oauth2-proxy/templates/httproute.yaml Outdated
Comment thread helm/oauth2-proxy/Chart.yaml Outdated
In order to apply security policies from gateway api implementations
like Envoy Gateway to the HTTPRoute I have added an optional name
attribute to the rules. These name attributes can be matched by the
sectionName of other resources.

Signed-off-by: Thomas Boerger <thomas@webhippie.de>
@tboerger tboerger force-pushed the feat/gateway-rule-name branch from ab4af24 to 9539190 Compare May 21, 2026 08:17
@tboerger
Copy link
Copy Markdown
Contributor Author

@pierluigilenoci sorry for the delay, I have integrated your requested changes now.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread helm/oauth2-proxy/Chart.yaml
Update the Helm chart README to:
- include the optional 'name' field in the Advanced Gateway API
  configuration example
- add a new subsection explaining how rules[].name maps to sectionName
  on policies (SecurityPolicy, BackendTrafficPolicy, etc.) so that
  consumers can target individual HTTPRoute rules.

Addresses Copilot review comment on Chart.yaml:37.

Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@pierluigilenoci pierluigilenoci merged commit 529c2f6 into oauth2-proxy:main May 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants