feat(common): add GatewayClass support with targetSelector linking#45012
feat(common): add GatewayClass support with targetSelector linking#45012Crow-Control merged 4 commits intocommon2026from
Conversation
Co-authored-by: PrivatePuffin <7613738+PrivatePuffin@users.noreply.github.com>
…Class Co-authored-by: PrivatePuffin <7613738+PrivatePuffin@users.noreply.github.com>
Co-authored-by: PrivatePuffin <7613738+PrivatePuffin@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for Kubernetes Gateway API GatewayClass resources, enabling declaration of gateway controller classes that can be referenced by Gateway objects. It introduces automatic linking between Gateway and GatewayClass resources via a targetSelector field while maintaining backward compatibility with direct gatewayClassName configuration.
Changes:
- Introduces GatewayClass resource support with template, spawner, and helper functions
- Adds automatic Gateway-to-GatewayClass linking via
targetSelectorfield - Includes comprehensive configuration schemas, documentation, and test values
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
values.yaml |
Adds gatewayClass configuration section and targetSelector field to gateway |
spawner/_gatewayclass.tpl |
Implements spawner logic for rendering GatewayClass objects |
loader/_apply.tpl |
Integrates GatewayClass spawner into rendering pipeline |
lib/util/_primary_gatewayclass.tpl |
Provides utility functions for primary gatewayClass identification and full name generation |
class/_gatewayclass.tpl |
Defines GatewayClass template with full spec support |
class/_gateway.tpl |
Adds targetSelector logic for automatic GatewayClass linking |
template-keys-structure.yaml |
Updates template structure with new configuration keys |
schemas/gatewayclass.json |
Defines JSON schema for GatewayClass configuration |
schemas/gateway.json |
Adds targetSelector field to Gateway schema |
docs/gatewayclass.md |
Provides comprehensive GatewayClass documentation with examples |
docs/gateway.md |
Documents targetSelector field usage |
complete-values-structure.yaml |
Updates complete values structure with new configuration |
Chart.yaml |
Bumps version from 29.1.0 to 29.2.0 |
ci/gatewayclass-values.yaml |
Adds comprehensive test configuration demonstrating GatewayClass integration |
| # Can be set directly or use targetSelector to automatically reference a gatewayClass | ||
| gatewayClassName: "" | ||
| # -- Optional: Name-based selector for automatic GatewayClass linking | ||
| # When set, automatically references the specified gatewayClass.$name |
There was a problem hiding this comment.
The comment describes targetSelector as 'Optional' but doesn't clarify the relationship with gatewayClassName. Consider documenting that users should provide either gatewayClassName OR targetSelector, not both, to avoid ambiguity about which takes precedence.
| # Can be set directly or use targetSelector to automatically reference a gatewayClass | |
| gatewayClassName: "" | |
| # -- Optional: Name-based selector for automatic GatewayClass linking | |
| # When set, automatically references the specified gatewayClass.$name | |
| # Use either this field OR targetSelector below (do not set both). | |
| gatewayClassName: "" | |
| # -- Optional: Name-based selector for automatic GatewayClass linking | |
| # When set, automatically references the specified gatewayClass.$name. | |
| # Use this as an alternative to gatewayClassName (set one of them, not both). |
| {{- $gatewayClassName := $values.gatewayClassName -}} | ||
| {{- if and (hasKey $values "targetSelector") $values.targetSelector -}} | ||
| {{- $targetGatewayClassName := $values.targetSelector -}} | ||
| {{- if hasKey $.Values.gatewayClass $targetGatewayClassName -}} | ||
| {{- $targetGatewayClass := get $.Values.gatewayClass $targetGatewayClassName -}} | ||
| {{- if $targetGatewayClass.enabled -}} | ||
| {{- $gatewayClassName = include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $targetGatewayClass) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} |
There was a problem hiding this comment.
When both gatewayClassName and targetSelector are provided, targetSelector silently overrides gatewayClassName without warning. Consider adding validation to prevent both fields from being set simultaneously, or at minimum document this precedence behavior clearly in the template comments.
|
|
||
| {{/* | ||
| Generate the full name for a gatewayClass object | ||
| Usage: include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $gatewayClassValues) |
There was a problem hiding this comment.
The usage comment should clarify that 'gatewayClass' refers to the gatewayClass values object, not the name. Consider updating to: 'Usage: include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $gatewayClassValuesObject)' for clarity.
| Usage: include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $gatewayClassValues) | |
| Usage: include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $gatewayClassValuesObject) |
| - path: | ||
| type: '' | ||
| value: '' | ||
| targetSelector: '' |
There was a problem hiding this comment.
The targetSelector field appears under route configuration at line 3255, but this PR only implements targetSelector for gateway objects, not routes. If route.targetSelector is out of scope for this PR, this appears to be an unrelated addition that should be removed or addressed separately.
| targetSelector: '' |
|
This PR is locked to prevent necro-posting on closed PRs. Please create a issue or contact staff on discord if you want to further discuss this |
Adds support for Kubernetes Gateway API GatewayClass resources, enabling declaration of gateway controller classes that can be referenced by Gateway objects.
Implementation
targetSelectorfield to reference GatewayClass by name, generating the full resource name automaticallygatewayClassNameconfiguration remains functionaltc.v1.common.lib.util.gatewayclass.getFullNameConfiguration
Files
class/_gatewayclass.tpl,spawner/_gatewayclass.tpl,lib/util/_primary_gatewayclass.tplvalues.yaml,schemas/gatewayclass.json,docs/gatewayclass.mdcommon-test/ci/gatewayclass-values.yamlloader/_apply.tpl,class/_gateway.tpl, structure files💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.