diff --git a/cmd/aeraki/main.go b/cmd/aeraki/main.go index fe0f08ac1..8ef258cec 100644 --- a/cmd/aeraki/main.go +++ b/cmd/aeraki/main.go @@ -72,7 +72,7 @@ func main() { args.PodName = env.RegisterStringVar("POD_NAME", args.ServerID, "").Get() args.RootNamespace = env.RegisterStringVar("AERAKI_NAMESPACE", args.RootNamespace, "").Get() - args.EnableEnvoyFilterNSScope = env.RegisterBoolVar("AERAKI_ENABLE_ENVOY_FILTER_NS_SCOPE", + args.EnableEnvoyFilterNSScope = env.RegisterBoolVar(constants.DefaultAerakiEnableEnvoyFilterNsScopeName, args.EnableEnvoyFilterNSScope, "").Get() args.IstiodAddr = env.RegisterStringVar("AERAKI_ISTIOD_ADDR", args.IstiodAddr, "").Get() args.AerakiXdsAddr = env.RegisterStringVar("AERAKI_XDS_ADDR", constants.DefaultAerakiXdsAddr, "").Get() diff --git a/pkg/config/constants/constants.go b/pkg/config/constants/constants.go index e6fec3928..0a7235bc4 100644 --- a/pkg/config/constants/constants.go +++ b/pkg/config/constants/constants.go @@ -21,4 +21,8 @@ const ( DefaultAerakiXdsPort = ":15010" // DefaultAerakiXdsAddr is the default value for Aeraki xds address DefaultAerakiXdsAddr = "aeraki.istio-system" + // DefaultAerakiEnableEnvoyFilterNsScopeName is the name for Aeraki to place envoyFilters scope + // False(Default): The generated envoyFilters will be placed under Istio root namespace + // True: The generated envoyFilters will be placed under the service namespace + DefaultAerakiEnableEnvoyFilterNsScopeName = "AERAKI_ENABLE_ENVOY_FILTER_NS_SCOPE" ) diff --git a/pkg/envoyfilter/controller.go b/pkg/envoyfilter/controller.go index 88bf1e34a..d7fd1fef9 100644 --- a/pkg/envoyfilter/controller.go +++ b/pkg/envoyfilter/controller.go @@ -131,7 +131,13 @@ func (c *Controller) pushEnvoyFilters2APIServer() error { return fmt.Errorf("failed to generate EnvoyFilter: %v", err) } - existingEnvoyFilters, _ := c.istioClientset.NetworkingV1alpha3().EnvoyFilters("").List(context.TODO(), v1.ListOptions{ + listNamespace := "" + if c.namespaceScoped { + listNamespace = c.namespace + controllerLog.Infof("listing EnvoyFilter from namespace=%s due to %s=true", + listNamespace, constants.DefaultAerakiEnableEnvoyFilterNsScopeName) + } + existingEnvoyFilters, _ := c.istioClientset.NetworkingV1alpha3().EnvoyFilters(listNamespace).List(context.TODO(), v1.ListOptions{ LabelSelector: "manager=" + constants.AerakiFieldManager, })