@@ -34,6 +34,8 @@ import (
3434 "github.com/kedacore/http-add-on/pkg/queue"
3535 "github.com/kedacore/http-add-on/pkg/routing"
3636 "github.com/kedacore/http-add-on/pkg/util"
37+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
38+ "k8s.io/apimachinery/pkg/labels"
3739)
3840
3941var (
@@ -104,7 +106,24 @@ func main() {
104106
105107 queues := queue .NewMemory ()
106108
107- sharedInformerFactory := informers .NewSharedInformerFactory (httpCl , servingCfg .ConfigMapCacheRsyncPeriod )
109+ var labelSelector labels.Selector
110+ if servingCfg .WatchLabel != "" {
111+ labelSelector , err = labels .Parse (servingCfg .WatchLabel )
112+ if err != nil {
113+ setupLog .Error (err , "invalid WatchLabel format" )
114+ os .Exit (1 )
115+ }
116+ setupLog .Info ("watching label" , "label" , servingCfg .WatchLabel )
117+ } else {
118+ labelSelector = labels .Everything ()
119+ setupLog .Info ("watching all labels" )
120+ }
121+
122+ sharedInformerFactory := informers .NewSharedInformerFactoryWithOptions (httpCl , servingCfg .ConfigMapCacheRsyncPeriod ,
123+ informers .WithTweakListOptions (func (options * v1.ListOptions ) {
124+ options .LabelSelector = labelSelector .String ()
125+ }),
126+ )
108127 routingTable , err := routing .NewTable (sharedInformerFactory , servingCfg .WatchNamespace , queues )
109128 if err != nil {
110129 setupLog .Error (err , "fetching routing table" )
0 commit comments