diff --git a/api/v1alpha1/envoygateway_types.go b/api/v1alpha1/envoygateway_types.go index d479d3f7f9e..66abfdec9c8 100644 --- a/api/v1alpha1/envoygateway_types.go +++ b/api/v1alpha1/envoygateway_types.go @@ -214,19 +214,19 @@ type KubernetesWatchMode struct { // KubernetesWatchModeTypeNamespaceSelectors are currently supported // By default, when this field is unset or empty, Envoy Gateway will watch for input namespaced resources // from all namespaces. - Type KubernetesWatchModeType + Type KubernetesWatchModeType `json:"type,omitempty"` // Namespaces holds the list of namespaces that Envoy Gateway will watch for namespaced scoped // resources such as Gateway, HTTPRoute and Service. // Note that Envoy Gateway will continue to reconcile relevant cluster scoped resources such as // GatewayClass that it is linked to. Precisely one of Namespaces and NamespaceSelectors must be set - Namespaces []string + Namespaces []string `json:"namespaces,omitempty"` // NamespaceSelectors holds a list of labels that namespaces have to have in order to be watched. // Note this doesn't set the informer to watch the namespaces with the given labels. Informer still // watches all namespaces. But the events for objects whois namespce have no given labels // will be filtered out. Precisely one of Namespaces and NamespaceSelectors must be set - NamespaceSelectors []string `json:"namespaces,omitempty"` + NamespaceSelectors []string `json:"namespaceSelectors,omitempty"` } // KubernetesDeployMode holds configuration for how to deploy managed resources such as the Envoy Proxy diff --git a/internal/envoygateway/config/decoder_test.go b/internal/envoygateway/config/decoder_test.go index ebd1bf145e6..80fdc461ff8 100644 --- a/internal/envoygateway/config/decoder_test.go +++ b/internal/envoygateway/config/decoder_test.go @@ -234,6 +234,55 @@ func TestDecode(t *testing.T) { }, expect: true, }, + { + in: inPath + "gateway-ns-watch.yaml", + out: &v1alpha1.EnvoyGateway{ + TypeMeta: metav1.TypeMeta{ + Kind: v1alpha1.KindEnvoyGateway, + APIVersion: v1alpha1.GroupVersion.String(), + }, + EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ + Provider: &v1alpha1.EnvoyGatewayProvider{ + Type: v1alpha1.ProviderTypeKubernetes, + Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ + Watch: &v1alpha1.KubernetesWatchMode{ + Type: v1alpha1.KubernetesWatchModeTypeNamespaces, + Namespaces: []string{ + "ns-a", + "ns-b", + }, + }, + }, + }, + Gateway: v1alpha1.DefaultGateway(), + }, + }, + expect: true, + }, + { + in: inPath + "gateway-nsselector-watch.yaml", + out: &v1alpha1.EnvoyGateway{ + TypeMeta: metav1.TypeMeta{ + Kind: v1alpha1.KindEnvoyGateway, + APIVersion: v1alpha1.GroupVersion.String(), + }, + EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{ + Provider: &v1alpha1.EnvoyGatewayProvider{ + Type: v1alpha1.ProviderTypeKubernetes, + Kubernetes: &v1alpha1.EnvoyGatewayKubernetesProvider{ + Watch: &v1alpha1.KubernetesWatchMode{ + Type: v1alpha1.KubernetesWatchModeTypeNamespaceSelectors, + NamespaceSelectors: []string{ + "label-a", + }, + }, + }, + }, + Gateway: v1alpha1.DefaultGateway(), + }, + }, + expect: true, + }, { in: inPath + "invalid-gateway-logging.yaml", expect: false, diff --git a/internal/envoygateway/config/testdata/decoder/in/gateway-ns-watch.yaml b/internal/envoygateway/config/testdata/decoder/in/gateway-ns-watch.yaml new file mode 100644 index 00000000000..44c995fc64d --- /dev/null +++ b/internal/envoygateway/config/testdata/decoder/in/gateway-ns-watch.yaml @@ -0,0 +1,12 @@ +apiVersion: gateway.envoyproxy.io/v1alpha1 +kind: EnvoyGateway +gateway: + controllerName: gateway.envoyproxy.io/gatewayclass-controller +provider: + type: Kubernetes + kubernetes: + watch: + type: Namespaces + namespaces: + - ns-a + - ns-b diff --git a/internal/envoygateway/config/testdata/decoder/in/gateway-nsselector-watch.yaml b/internal/envoygateway/config/testdata/decoder/in/gateway-nsselector-watch.yaml new file mode 100644 index 00000000000..4bc7369f6ae --- /dev/null +++ b/internal/envoygateway/config/testdata/decoder/in/gateway-nsselector-watch.yaml @@ -0,0 +1,11 @@ +apiVersion: gateway.envoyproxy.io/v1alpha1 +kind: EnvoyGateway +gateway: + controllerName: gateway.envoyproxy.io/gatewayclass-controller +provider: + type: Kubernetes + kubernetes: + watch: + type: NamespaceSelectors + namespaceSelectors: + - label-a diff --git a/site/content/en/latest/api/extension_types.md b/site/content/en/latest/api/extension_types.md index 8f382fa2b11..da5c6ec4761 100644 --- a/site/content/en/latest/api/extension_types.md +++ b/site/content/en/latest/api/extension_types.md @@ -1134,9 +1134,9 @@ _Appears in:_ | Field | Description | | --- | --- | -| `Type` _[KubernetesWatchModeType](#kuberneteswatchmodetype)_ | Type indicates what watch mode to use. KubernetesWatchModeTypeNamespaces and KubernetesWatchModeTypeNamespaceSelectors are currently supported By default, when this field is unset or empty, Envoy Gateway will watch for input namespaced resources from all namespaces. | -| `Namespaces` _string array_ | Namespaces holds the list of namespaces that Envoy Gateway will watch for namespaced scoped resources such as Gateway, HTTPRoute and Service. Note that Envoy Gateway will continue to reconcile relevant cluster scoped resources such as GatewayClass that it is linked to. Precisely one of Namespaces and NamespaceSelectors must be set | -| `namespaces` _string array_ | NamespaceSelectors holds a list of labels that namespaces have to have in order to be watched. Note this doesn't set the informer to watch the namespaces with the given labels. Informer still watches all namespaces. But the events for objects whois namespce have no given labels will be filtered out. Precisely one of Namespaces and NamespaceSelectors must be set | +| `type` _[KubernetesWatchModeType](#kuberneteswatchmodetype)_ | Type indicates what watch mode to use. KubernetesWatchModeTypeNamespaces and KubernetesWatchModeTypeNamespaceSelectors are currently supported By default, when this field is unset or empty, Envoy Gateway will watch for input namespaced resources from all namespaces. | +| `namespaces` _string array_ | Namespaces holds the list of namespaces that Envoy Gateway will watch for namespaced scoped resources such as Gateway, HTTPRoute and Service. Note that Envoy Gateway will continue to reconcile relevant cluster scoped resources such as GatewayClass that it is linked to. Precisely one of Namespaces and NamespaceSelectors must be set | +| `namespaceSelectors` _string array_ | NamespaceSelectors holds a list of labels that namespaces have to have in order to be watched. Note this doesn't set the informer to watch the namespaces with the given labels. Informer still watches all namespaces. But the events for objects whois namespce have no given labels will be filtered out. Precisely one of Namespaces and NamespaceSelectors must be set | #### KubernetesWatchModeType