diff --git a/pkg/cmconfig/controller.go b/pkg/cmconfig/controller.go index 89a23ab867..561f206a48 100644 --- a/pkg/cmconfig/controller.go +++ b/pkg/cmconfig/controller.go @@ -90,11 +90,13 @@ func (c *ConfigMapConfigController) DisableASM() { // SetASMReadyTrue update the ASMReady to True. func (c *ConfigMapConfigController) SetASMReadyTrue() { + klog.V(0).Info("SetASMReadyTrue") c.updateASMReady(trueValue) } // SetASMReadyFalse update the ASMReady to False. func (c *ConfigMapConfigController) SetASMReadyFalse() { + klog.V(0).Info("SetASMReadyFalse") c.updateASMReady(falseValue) } @@ -125,10 +127,15 @@ func (c *ConfigMapConfigController) RegisterInformer(configMapInformer cache.Sha } func (c *ConfigMapConfigController) processItem(obj interface{}, cancel func()) { + klog.V(4).Infof("ConfigMapConfigController.processItem()") + configMap, ok := obj.(*v1.ConfigMap) if !ok { klog.Errorf("ConfigMapConfigController: failed to convert informer object to ConfigMap.") } + + klog.V(3).Infof("ConfigMapConfigController.processItem '%s.%s'", configMap.Namespace, configMap.Name) + if configMap.Namespace != c.configMapNamespace || configMap.Name != c.configMapName { return } diff --git a/pkg/context/context.go b/pkg/context/context.go index 93f0b7d6f9..71c881608a 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -28,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/dynamic" "k8s.io/client-go/dynamic/dynamicinformer" + informers "k8s.io/client-go/informers" informerv1 "k8s.io/client-go/informers/core/v1" discoveryinformer "k8s.io/client-go/informers/discovery/v1" informernetworking "k8s.io/client-go/informers/networking/v1" @@ -224,8 +225,10 @@ func (ctx *ControllerContext) Init() { klog.V(2).Infof("Controller Context initializing with %+v", ctx.ControllerContextConfig) // Initialize controller context internals based on ASMConfigMap if ctx.EnableASMConfigMap { - configMapInformer := informerv1.NewConfigMapInformer(ctx.KubeClient, ctx.Namespace, ctx.ResyncPeriod, utils.NewNamespaceIndexer()) - ctx.ConfigMapInformer = configMapInformer + klog.Infof("ASMConfigMap is enabled") + + informerFactory := informers.NewSharedInformerFactoryWithOptions(ctx.KubeClient, ctx.ResyncPeriod, informers.WithNamespace(ctx.ASMConfigMapNamespace)) + ctx.ConfigMapInformer = informerFactory.Core().V1().ConfigMaps().Informer() ctx.ASMConfigController = cmconfig.NewConfigMapConfigController(ctx.KubeClient, ctx.Recorder(ctx.ASMConfigMapNamespace), ctx.ASMConfigMapNamespace, ctx.ASMConfigMapName) cmConfig := ctx.ASMConfigController.GetConfig() @@ -235,7 +238,6 @@ func (ctx *ControllerContext) Init() { ctx.ASMConfigController.SetASMReadyFalse() } } - } func (ctx *ControllerContext) initEnableASM() { @@ -247,6 +249,8 @@ func (ctx *ControllerContext) initEnableASM() { destinationRuleCRDName = "destinationrules.networking.istio.io" ) + klog.V(0).Infof("ASM mode is enabled from ConfigMap") + apiextensionClient, err := apiextensionsclientset.NewForConfig(ctx.KubeConfig) if err != nil { msg := fmt.Sprintf("Failed to create ApiextensionClient for DestinationRule, disabling ASM Mode, error: %s", err)