このページは、まだ日本語ではご利用いただけません。翻訳中です。
Limiting namespaces watched by ControlPlane
By default, Kong Gateway Operator’s ControlPlane watches all namespaces.
This provides a convenient out-of-the-box experience but may not suit all production environments, especially those where multiple teams share the same cluster or in multitenant setups.
To limit the namespaces watched by ControlPlane, you can set the watchNamespaces field in the ControlPlane’s spec.
ControlPlane’s watchNamespaces field
The spec.watchNamespaces.type field accepts three values to control this behavior:
-
all(default): Watches resources in all namespaces. -
own: Watches resources only in theControlPlane’s own namespace. -
list: Watches resources in theControlPlane’s own namespace and in the specified list of additional namespaces. When usinglist, theControlPlane’s own namespace is automatically added to the list of watched namespaces, because this behavior is required by Kong Ingress Controller.
By default, the publish service (theServicefor theDataPlane, exposed by Kong Gateway) is created in the same namespace as theControlPlane.
Note: Setting this field in
ControlPlanewill configure theCONTROLLER_WATCH_NAMESPACEenvironment variable in the managed Kong Ingress Controller. If you manually set theCONTROLLER_WATCH_NAMESPACEenvironment variable throughpodTemplateSpec, it will override this configuration.
Specify a list of namespaces to watch
all and own types are self-explanatory and do not require any further changes
or additional resources.
The list type requires 2 additional steps:
-
You must specify the namespaces to watch in the
spec.watchNamespaces.listfield.spec: watchNamespaces: type: list list: - namespace-a - namespace-b -
You must create a
WatchNamespaceGrantresource in each of the specified namespaces. This resource grants theControlPlanepermission to watch resources in the specified namespace.
It can be defined as:apiVersion: gateway-operator.konghq.com/v1alpha1 kind: WatchNamespaceGrant metadata: name: watch-namespace-grant namespace: namespace-a spec: from: - group: gateway-operator.konghq.com kind: ControlPlane namespace: control-plane-namespace
For more information on the WatchNamespaceGrant CRD, check CRD reference.