You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/06/30 08:32:47 UTC

[GitHub] [apisix-ingress-controller] wolgod opened a new issue, #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

wolgod opened a new issue, #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124

   ### Issue description
   
   1.  在1.4.0 之后appNamespaces 被废弃了,如果我想通过namespaceSelector 监听指定标签的namespace的话,appNamespaces是不是需要配置为"" 还是使用默认值?
   2. 我把appNamespaces 设置为”“,并且指定namespaceSelector,同时设置了namespace的label,但是我发现如果我新增一个namespace并且设置了ingress controller namespaceSelector的lable,这时并不生效,我必须重启ingress-controller,我新创建的ns 下的apisixroute 才能被监听到
   3. 我把appNamespaces 设置为”“,并且指定namespaceSelector,同时设置了namespace的label,我去掉一个namespace的label,这个时候我再当前这个namespace下做的变更还是会被ingress controller监听到
   
   ### Environment
   
   - your apisix-ingress-controller version (output of apisix-ingress-controller version --long):1.4.1
   - your Kubernetes cluster version (output of kubectl version):1.20
   - if you run apisix-ingress-controller in Bare-metal environment, also show your OS version (uname -a):centos-7
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1173497884

   @wolgod I have created a PR to fix it. #1130 
   I will add a full e2e test case later.
   
   You can use the code that includes the PR to verify


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] wolgod commented on issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
wolgod commented on issue #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1173344543

   My test scenario is that when I cancel the label of an ns, I find that I can still listen to the events of apisixroute under this ns
   `
   func (c *namespaceController) onUpdate(pre, cur interface{}) {
   	oldNamespace := pre.(*corev1.Namespace)
   	newNamespace := cur.(*corev1.Namespace)
   	if oldNamespace.ResourceVersion >= newNamespace.ResourceVersion {
   		return
   	}
   	key, err := cache.MetaNamespaceKeyFunc(cur)
   	if err != nil {
   		log.Errorf("found Namespace resource with error: %s", err)
   		return
   	}
   	c.workqueue.Add(&types.Event{
   		Type:   types.EventUpdate,
   		Object: key,
   	})
   }
   `
   
   `
   func (c *namespaceController) sync(ctx context.Context, ev *types.Event) error {
   	if ev.Type != types.EventDelete {
   		// check the labels of specify namespace
   		namespace, err := c.controller.kubeClient.Client.CoreV1().Namespaces().Get(ctx, ev.Object.(string), metav1.GetOptions{})
   		if err != nil {
   			return err
   		} else {
   			// if labels of namespace contains the watchingLabels, the namespace should be set to controller.watchingNamespace
   			if c.controller.watchingLabels.IsSubsetOf(namespace.Labels) {
   				c.controller.watchingNamespace.Store(namespace.Name, struct{}{})
   			}
   		}
   	} else { // type == types.EventDelete
   		namespace := ev.Tombstone.(*corev1.Namespace)
   		if _, ok := c.controller.watchingNamespace.Load(namespace.Name); ok {
   			c.controller.watchingNamespace.Delete(namespace.Name)
   		}
   		// do nothing, if the namespace did not in controller.watchingNamespace
   	}
   	return nil
   }
   `
   
   In my opinion, the label removal triggers the update event, but the sync does not remove the monitoring of this ns. I wonder if this logic is originally designed like this?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 closed issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
tao12345666333 closed issue #1124: request help: APISIX Ingress     namespaceSelector and appNamespaces
URL: https://github.com/apache/apisix-ingress-controller/issues/1124


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1171013481

   > 在1.4.0 之后appNamespaces 被废弃了,如果我想通过namespaceSelector 监听指定标签的namespace的话,appNamespaces是不是需要配置为"" 还是使用默认值?
   
   The `appNamespaces` 's default value is ""
   
   
   > 2. 我把appNamespaces 设置为”“,并且指定namespaceSelector,同时设置了namespace的label,但是我发现如果我新增一个namespace并且设置了ingress controller namespaceSelector的lable,这时并不生效,我必须重启ingress-controller,我新创建的ns 下的apisixroute 才能被监听到
   > 3. 我把appNamespaces 设置为”“,并且指定namespaceSelector,同时设置了namespace的label,我去掉一个namespace的label,这个时候我再当前这个namespace下做的变更还是会被ingress controller监听到,只有当我重启ingress controller之后这个namespace下的变动才不会被监听到
   
   So in general, in your test, you found that the namespace of APISIX Ingress controller watch cannot be dynamically adjusted, right?
   
   
   cc @lingsamuel  @AlinsRan


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] wolgod commented on issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
wolgod commented on issue #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1171140783

   1. 是的,不过在APISIX Ingress controller 的官方chart里values默认是appNamespaces: ["*"] ,我理解如果我想使用namespaceSelector选定指定namespace的话,应该把appNamespaces设为appNamespaces:[""]
   2和3的问题,就是我appNamespaces设为"",我想通过namespaceSelector动态控制监听,不过我发现我更改namespace的label后,并没有动态调整,我等了十多分钟后,发现还是无法动态监听,控制台也没有异常,只能重启ingress才能达到我想要的效果


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1124: request help: APISIX Ingress namespaceSelector and appNamespaces

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on issue #1124:
URL: https://github.com/apache/apisix-ingress-controller/issues/1124#issuecomment-1171906541

   Sorry for mistake. I have updated the reply. The default value is `"*"`  https://github.com/apache/apisix-ingress-controller/blob/810f1a1c5b232808e77f8f153d3ec90c3008e3c0/pkg/config/config.go#L37


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org