diff --git a/pilot/pkg/features/pilot.go b/pilot/pkg/features/pilot.go index 0a12a4d3dca0..994b8c4976a9 100644 --- a/pilot/pkg/features/pilot.go +++ b/pilot/pkg/features/pilot.go @@ -389,6 +389,10 @@ var ( "If enabled, pilot will authorize XDS clients, to ensure they are acting only as namespaces they have permissions for.", ).Get() + EnableServiceEntrySelectPods = env.RegisterBoolVar("PILOT_ENABLE_SERVICEENTRY_SELECT_PODS", true, + "If enabled, service entries with selectors will select pods from the cluster. "+ + "It is safe to disable it if you are quite sure you don't need this feature").Get() + InjectionWebhookConfigName = env.RegisterStringVar("INJECTION_WEBHOOK_CONFIG_NAME", "istio-sidecar-injector", "Name of the mutatingwebhookconfiguration to patch, if istioctl is not used.").Get() diff --git a/pilot/pkg/serviceregistry/kube/controller/multicluster.go b/pilot/pkg/serviceregistry/kube/controller/multicluster.go index 1c23570107f7..60a30925fa06 100644 --- a/pilot/pkg/serviceregistry/kube/controller/multicluster.go +++ b/pilot/pkg/serviceregistry/kube/controller/multicluster.go @@ -174,7 +174,7 @@ func (m *Multicluster) ClusterAdded(cluster *multicluster.Cluster, clusterStopCh m.m.Unlock() // TODO move instance cache out of registries - if m.serviceEntryStore != nil { + if m.serviceEntryStore != nil && features.EnableServiceEntrySelectPods { // Add an instance handler in the kubernetes registry to notify service entry store about pod events kubeRegistry.AppendWorkloadHandler(m.serviceEntryStore.WorkloadInstanceHandler) }