Hi, Wojciech,
We have a usage that Pods in a daemonset are watching one resources based on the label selector. We want to utilize the indexedTrigger
(
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L265 ) to reduce the watchers number processing the event.
However, after checking the code, seems currently this feature only support field selector, as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L471 only check the
pred.Field
. Is the understanding correct? If yes, are there any special reason that no label selector support yet? We are considering to add the label selector support but want to make sure it’s ok to do that way.
BTW, for the code at
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L469, why do we need loop through the pred.IndexField? Per my understanding, the pred.IndexField will decide how the store is indexed, but have
nothing to do with the watch trigger, right? For example, the client can have field selector LIST based on field A while field selector WATCH based on field B, then we can have indexField to be field A which will reduce the list cost, and have indexTrigger
based on fieldB, which will reduce the watch cost, am I right? Of course, normally the list watch will have list/watch using the same selector, but it’s not mandatory, right?
Thanks
--jyh
Hi, Wojciech,
We have a usage that Pods in a daemonset are watching one resources based on the label selector. We want to utilize the indexedTrigger
( https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L265 ) to reduce the watchers number processing the event.
However, after checking the code, seems currently this feature only support field selector, as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L471 only check the pred.Field . Is the understanding correct? If yes, are there any special reason that no label selector support yet? We are considering to add the label selector support but want to make sure it’s ok to do that way.
BTW, for the code at https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L469, why do we need loop through the pred.IndexField? Per my understanding, the pred.IndexField will decide how the store is indexed, but have nothing to do with the watch trigger, right? For example, the client can have field selector LIST based on field A while field selector WATCH based on field B, then we can have indexField to be field A which will reduce the list cost, and have indexTrigger based on fieldB, which will reduce the watch cost, am I right? Of course, normally the list watch will have list/watch using the same selector, but it’s not mandatory, right?
Thanks
--jyh
Thanks for the reply.
“The lack of good usecase” is a good reason. Otehrwise, if we add the label selector index trigger and there is no usage case in the core k8s components, then it’s not easy to verify it.
Do you think if we should change our data model to use field index (changing data model is always challenge)? Or if you think it would be ok to have the label index trigger in the upstream k8s?
Thanks
-jyh
From:
Wojciech Tyczyński <woj...@google.com>
Date: Wednesday, January 5, 2022 at 6:32 AM
To: Jiang, Yunhong <yunh...@ebay.com>
Cc: kubernetes-sig...@googlegroups.com <kubernetes-sig...@googlegroups.com>
Subject: Re: One question on adding label selector based indexedTrigger at watch cache
External Email
Thanks for the reply.
“The lack of good usecase” is a good reason. Otehrwise, if we add the label selector index trigger and there is no usage case in the core k8s components, then it’s not easy to verify it.
Do you think if we should change our data model to use field index (changing data model is always challenge)? Or if you think it would be ok to have the label index trigger in the upstream k8s?