Skip to content

feat(common): add GatewayClass support with targetSelector linking#45012

Merged
Crow-Control merged 4 commits intocommon2026from
copilot/sub-pr-41017-yet-again
Feb 15, 2026
Merged

feat(common): add GatewayClass support with targetSelector linking#45012
Crow-Control merged 4 commits intocommon2026from
copilot/sub-pr-41017-yet-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 15, 2026

Adds support for Kubernetes Gateway API GatewayClass resources, enabling declaration of gateway controller classes that can be referenced by Gateway objects.

Implementation

  • GatewayClass resource: New template class, spawner, and helper functions for creating GatewayClass objects with full spec support (controllerName, description, parametersRef)
  • Automatic linking: Gateway objects support targetSelector field to reference GatewayClass by name, generating the full resource name automatically
  • Backward compatibility: Direct gatewayClassName configuration remains functional
  • Helper extraction: Shared full-name generation logic extracted to tc.v1.common.lib.util.gatewayclass.getFullName

Configuration

gatewayClass:
  main:
    enabled: true
    controllerName: traefik.io/gateway-controller
    description: "Traefik-based gateway class"

gateway:
  main:
    enabled: true
    targetSelector: main  # References gatewayClass.main
    listeners:
      - name: http
        port: 80
        protocol: HTTP

Files

  • Templates: class/_gatewayclass.tpl, spawner/_gatewayclass.tpl, lib/util/_primary_gatewayclass.tpl
  • Configuration: values.yaml, schemas/gatewayclass.json, docs/gatewayclass.md
  • Tests: common-test/ci/gatewayclass-values.yaml
  • Updated: loader/_apply.tpl, class/_gateway.tpl, structure files
  • Version: 29.1.0 → 29.2.0

💡 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.

Copilot AI and others added 3 commits February 15, 2026 14:44
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>
Copilot AI changed the title [WIP] Remove env-list support and improve network policy feat(common): add GatewayClass support with targetSelector linking Feb 15, 2026
Copilot AI requested a review from Crow-Control February 15, 2026 14:50
@Crow-Control Crow-Control marked this pull request as ready for review February 15, 2026 14:55
Copilot AI review requested due to automatic review settings February 15, 2026 14:55
@Crow-Control Crow-Control merged commit 6d49ccb into common2026 Feb 15, 2026
2 checks passed
@Crow-Control Crow-Control deleted the copilot/sub-pr-41017-yet-again branch February 15, 2026 14:55
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 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 targetSelector field
  • 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

Comment on lines +852 to +855
# 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
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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).

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +31
{{- $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 -}}
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

{{/*
Generate the full name for a gatewayClass object
Usage: include "tc.v1.common.lib.util.gatewayclass.getFullName" (dict "rootCtx" $ "gatewayClass" $gatewayClassValues)
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
- path:
type: ''
value: ''
targetSelector: ''
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
targetSelector: ''

Copilot uses AI. Check for mistakes.
@truecharts-admin
Copy link
Copy Markdown
Contributor

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

@trueforge-org trueforge-org locked as resolved and limited conversation to collaborators Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants