Skip to content

Commit 91c0913

Browse files
committed
Add gatewayDeploymentMode field to GatewayAPI spec
- Add GatewayDeploymentMode type with ControllerNamespace and GatewayNamespace options - Default to ControllerNamespace when not specified in the controller Reconcile - Regenerate CRD manifest and deepcopy methods
1 parent 5bfadca commit 91c0913

4 files changed

Lines changed: 47 additions & 0 deletions

File tree

api/v1/gatewayapi_types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ type GatewayAPISpec struct {
6464
// +optional
6565
GatewayCertgenJob *GatewayCertgenJob `json:"gatewayCertgenJob,omitempty"`
6666

67+
// Configures where Envoy Gateway deploys managed gateway proxy workloads.
68+
//
69+
// - "ControllerNamespace" deploys managed proxy workloads in the Envoy Gateway
70+
// controller namespace.
71+
// - "GatewayNamespace" deploys managed proxy workloads in each Gateway's
72+
// namespace.
73+
//
74+
// If not specified, defaults to "ControllerNamespace".
75+
// +kubebuilder:default=ControllerNamespace
76+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="gatewayDeploymentMode is immutable once set"
77+
// +optional
78+
GatewayDeploymentMode *GatewayDeploymentMode `json:"gatewayDeploymentMode,omitempty"`
79+
6780
// Configures how to manage and update Gateway API CRDs. The default behaviour - which is
6881
// used when this field is not set, or is set to "PreferExisting" - is that the Tigera
6982
// operator will create the Gateway API CRDs if they do not already exist, but will not
@@ -129,6 +142,14 @@ type GatewayClassSpec struct {
129142
GatewayService *GatewayService `json:"gatewayService,omitempty"`
130143
}
131144

145+
// +kubebuilder:validation:Enum=ControllerNamespace;GatewayNamespace
146+
type GatewayDeploymentMode string
147+
148+
const (
149+
GatewayDeploymentModeControllerNamespace GatewayDeploymentMode = "ControllerNamespace"
150+
GatewayDeploymentModeGatewayNamespace GatewayDeploymentMode = "GatewayNamespace"
151+
)
152+
132153
//+kubebuilder:object:root=true
133154
//+kubebuilder:resource:scope=Cluster
134155

api/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/gatewayapi/gatewayapi_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/runtime"
2727
"k8s.io/apimachinery/pkg/types"
28+
"k8s.io/utils/ptr"
2829
"k8s.io/utils/set"
2930
gapi "sigs.k8s.io/gateway-api/apis/v1"
3031
"sigs.k8s.io/yaml" // gopkg.in/yaml.v2 didn't parse all the fields but this package did
@@ -282,6 +283,10 @@ func (r *ReconcileGatewayAPI) Reconcile(ctx context.Context, request reconcile.R
282283
CurrentGatewayClasses: set.New[string](),
283284
}
284285

286+
if gatewayAPI.Spec.GatewayDeploymentMode == nil {
287+
gatewayAPI.Spec.GatewayDeploymentMode = ptr.To(operatorv1.GatewayDeploymentModeControllerNamespace)
288+
}
289+
285290
if gatewayAPI.Spec.EnvoyGatewayConfigRef != nil {
286291
if err = r.watchEnvoyGateway(*gatewayAPI.Spec.EnvoyGatewayConfigRef); err != nil {
287292
r.status.SetDegraded(operatorv1.ResourceReadError, "Error watching EnvoyGatewayConfigRef", err, log)

pkg/imports/crds/operator/operator.tigera.io_gatewayapis.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5710,6 +5710,22 @@ spec:
57105710
type: object
57115711
type: object
57125712
type: object
5713+
gatewayDeploymentMode:
5714+
default: ControllerNamespace
5715+
description: |-
5716+
Configures where Envoy Gateway deploys managed gateway proxy workloads.
5717+
- "ControllerNamespace" deploys managed proxy workloads in the Envoy Gateway
5718+
controller namespace.
5719+
- "GatewayNamespace" deploys managed proxy workloads in each Gateway's
5720+
namespace.
5721+
If not specified, defaults to "ControllerNamespace".
5722+
enum:
5723+
- ControllerNamespace
5724+
- GatewayNamespace
5725+
type: string
5726+
x-kubernetes-validations:
5727+
- message: gatewayDeploymentMode is immutable once set
5728+
rule: self == oldSelf
57135729
type: object
57145730
type: object
57155731
x-kubernetes-validations:

0 commit comments

Comments
 (0)