Skip to content

Commit

Permalink
deprecate configuring Contour with a Gateway controller name (project…
Browse files Browse the repository at this point in the history
…contour#6144)

Users should either statically configure Contour with
a specific Gateway ref, or use the Gateway provisioner
to dynamically provision Gateways.

Updates projectcontour#5923.

Signed-off-by: Steve Kriss <[email protected]>
  • Loading branch information
skriss authored Jan 31, 2024
1 parent ac49aee commit 62f81db
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ type GatewayConfig struct {
// GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
// If unset, the gatewayclass controller will not be started.
// Exactly one of ControllerName or GatewayRef must be set.
//
// Deprecated: users should use GatewayRef, or the Gateway provisioner,
// in place of this field. This field will be removed in a future release.
// +optional
ControllerName string `json:"controllerName,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions changelogs/unreleased/6144-skriss-deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Configuring Contour with a GatewayClass controller name is deprecated

Contour should no longer be configured with a GatewayClass controller name (`gateway.controllerName` in the config file or ContourConfiguration CRD).
Instead, either use a specific Gateway reference (`gateway.gatewayRef`), or use the Gateway provisioner.
`gateway.controllerName` will be removed in a future release.
7 changes: 7 additions & 0 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,13 @@ func (s *Server) doServe() error {
var gatewayRef *types.NamespacedName

if contourConfiguration.Gateway != nil {
// nolint:staticcheck
gatewayControllerName = contourConfiguration.Gateway.ControllerName

if len(gatewayControllerName) > 0 {
s.log.Warnf("DEPRECATED: gateway.controllerName is deprecated and will be removed in a future release. Use gateway.gatewayRef or the Gateway provisioner instead.")
}

if contourConfiguration.Gateway.GatewayRef != nil {
gatewayRef = &types.NamespacedName{
Namespace: contourConfiguration.Gateway.GatewayRef.Namespace,
Expand Down Expand Up @@ -1005,6 +1010,7 @@ func (s *Server) setupGatewayAPI(contourConfiguration contour_api_v1alpha1.Conto
needLeadershipNotification := []leadership.NeedLeaderElectionNotification{}

// Check if GatewayAPI is configured.
// nolint:staticcheck
if contourConfiguration.Gateway != nil && (contourConfiguration.Gateway.GatewayRef != nil || len(contourConfiguration.Gateway.ControllerName) > 0) {
switch {
// If a specific gateway was specified, we don't need to run the
Expand All @@ -1024,6 +1030,7 @@ func (s *Server) setupGatewayAPI(contourConfiguration contour_api_v1alpha1.Conto
// the appropriate gateway class and gateway to process.
default:
// Create and register the gatewayclass controller with the manager.
// nolint:staticcheck
gatewayClassControllerName := contourConfiguration.Gateway.ControllerName
gwClass, err := controller.RegisterGatewayClassController(
s.log.WithField("context", "gatewayclass-controller"),
Expand Down
1 change: 1 addition & 0 deletions cmd/contour/servecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_api_v1alpha
var gatewayConfig *contour_api_v1alpha1.GatewayConfig
if ctx.Config.GatewayConfig != nil {
gatewayConfig = &contour_api_v1alpha1.GatewayConfig{
// nolint:staticcheck
ControllerName: ctx.Config.GatewayConfig.ControllerName,
}

Expand Down
4 changes: 4 additions & 0 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down Expand Up @@ -4296,6 +4298,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down Expand Up @@ -4515,6 +4517,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions examples/render/contour-gateway-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down Expand Up @@ -4307,6 +4309,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions examples/render/contour-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down Expand Up @@ -4518,6 +4520,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down
4 changes: 4 additions & 0 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down Expand Up @@ -4515,6 +4517,8 @@ spec:
GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.
Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.
type: string
gatewayRef:
description: |-
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ type GatewayParameters struct {
// GatewayClass. The string takes the form of "projectcontour.io/<namespace>/contour".
// If unset, the gatewayclass controller will not be started.
// Exactly one of ControllerName or GatewayRef must be set.
//
// Deprecated: users should use GatewayRef, or the Gateway provisioner,
// in place of this field. This field will be removed in a future release.
ControllerName string `yaml:"controllerName,omitempty"`

// GatewayRef defines a specific Gateway that this Contour
Expand Down
2 changes: 2 additions & 0 deletions site/content/docs/main/config/api-reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -7644,6 +7644,8 @@ <h3 id="projectcontour.io/v1alpha1.GatewayConfig">GatewayConfig
GatewayClass. The string takes the form of &ldquo;projectcontour.io/<namespace>/contour&rdquo;.
If unset, the gatewayclass controller will not be started.
Exactly one of ControllerName or GatewayRef must be set.</p>
<p>Deprecated: users should use GatewayRef, or the Gateway provisioner,
in place of this field. This field will be removed in a future release.</p>
</td>
</tr>
<tr>
Expand Down
2 changes: 2 additions & 0 deletions site/content/docs/main/config/gateway-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ With static provisioning, Contour can be configured with either a [controller na
If configured with a controller name, Contour will process the oldest `GatewayClass`, its oldest `Gateway`, and that `Gateway's` routes, for the given controller name.
If configured with a specific gateway, Contour will process that `Gateway` and its routes.

**Note:** configuring Contour with a controller name is deprecated and will be removed in a future release. Use a specific gateway reference or dynamic provisioning instead.

In **dynamic** provisioning, the platform operator first deploys Contour's Gateway provisioner. Then, the platform operator defines a `Gateway` resource, and the provisioner automatically deploys a Contour instance that corresponds to the `Gateway's` configuration and will process that `Gateway` and its routes.

Static provisioning makes sense for users who:
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/main/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ The gateway configuration block is used to configure which gateway-api Gateway C

| Field Name | Type | Default | Description |
| -------------- | -------------- | ------- | ------------------------------------------------------------------------------ |
| controllerName | string | | Gateway Class controller name (i.e. projectcontour.io/gateway-controller). If set, Contour will reconcile the oldest GatewayClass, and its oldest Gateway, with this controller string. Only one of `controllerName` or `gatewayRef` must be set. |
| controllerName | string | | **DEPRECATED**: Use `gatewayRef` or the Gateway provisioner instead. This field will be removed in a future release. Gateway Class controller name (i.e. projectcontour.io/gateway-controller). If set, Contour will reconcile the oldest GatewayClass, and its oldest Gateway, with this controller string. Only one of `controllerName` or `gatewayRef` must be set. |
| gatewayRef | NamespacedName | | [Gateway namespace and name](#gateway-ref). If set, Contour will reconcile this specific Gateway. Only one of `controllerName` or `gatewayRef` must be set. |

### Gateway Ref
Expand Down
2 changes: 2 additions & 0 deletions site/content/guides/gateway-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ With static provisioning, Contour can be configured with either a [controller na
If configured with a controller name, Contour will process the oldest `GatewayClass`, its oldest `Gateway`, and that `Gateway's` routes, for the given controller name.
If configured with a specific gateway, Contour will process that `Gateway` and its routes.

**Note:** configuring Contour with a controller name is deprecated and will be removed in a future release. Use a specific gateway reference or dynamic provisioning instead.

In **dynamic** provisioning, the platform operator first deploys Contour's Gateway provisioner. Then, the platform operator defines a `Gateway` resource, and the provisioner automatically deploys a Contour instance that corresponds to the `Gateway's` configuration and will process that `Gateway` and its routes.

Static provisioning may be more appropriate for users who prefer the traditional model of deploying Contour, have just a single Contour instance, or have highly customized YAML for deploying Contour.
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var _ = Describe("Gateway API", func() {
Name: gateway.Name,
}
} else {
// nolint:staticcheck
contourConfig.GatewayConfig.ControllerName = string(gatewayClass.Spec.ControllerName)
}

Expand All @@ -113,6 +114,7 @@ var _ = Describe("Gateway API", func() {
Name: gateway.Name,
}
} else {
// nolint:staticcheck
contourConfiguration.Spec.Gateway.ControllerName = string(gatewayClass.Spec.ControllerName)
}

Expand Down

0 comments on commit 62f81db

Please sign in to comment.