DiscoverySelectors
A workload is included in the Service Mesh if it satisfies these two conditions:
By default, the control plane scans for workloads in every namespace within the cluster. This default behavior leads to two outcomes:
Discovery selectors allow a mesh administrator to manage which namespaces the control plane can monitor. The administrator uses a Kubernetes label selector to define the criteria for namespaces that should be visible to the control plane, effectively hiding any namespaces that don't meet these criteria.
Istiod will always open a watch to Kubernetes for all namespaces. However, discovery selectors will ignore objects that are not selected very early in its processing, minimizing costs.
The discoverySelectors
field takes an array of Kubernetes selectors that are applied to namespace labels. Each selector can be configured for various scenarios:
istio-discovery=enabled
label.istio-discovery=enabled
OR region=us-east1
.istio-discovery=enabled
AND the app=helloworld
label.It is important to note that discovery selectors do not function as a security boundary. Even with the discoverySelector
field configured, Istiod retains access to all namespaces.
When you have identified the namespaces to be included in the Service Mesh, you can configure discoverySelectors
either during or after the installation. This is done by adding the necessary selectors to the meshConfig.discoverySelectors
field within the Istio
resource. For instance, you could configure Istio to only discover namespaces that have the label istio-discovery=enabled
.
Prerequisites
Procedure
Apply a label to the namespace where the Istio control plane is running, such as the istio-system
namespace.
Update the Istio
control plane resource by adding a discoverySelectors
section that uses the same label.
Verify that every namespace intended to host workloads for the Service Mesh is tagged with both the discoverySelector
label and, if required, the relevant Istio injection label.