File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,12 @@ type Serving struct {
15
15
// WatchNamespace is the namespace to watch for new HTTPScaledObjects.
16
16
// Leave this empty to watch HTTPScaledObjects in all namespaces.
17
17
WatchNamespace string `envconfig:"KEDA_HTTP_WATCH_NAMESPACE" default:""`
18
+ // WatchLabel is the label to watch for new HTTPScaledObjects.
19
+ // Leave this empty to watch HTTPScaledObjects in all labels.
20
+ //
21
+ // Example:
22
+ // export KEDA_HTTP_WATCH_LABEL="scope=internal"
23
+ WatchLabel string `envconfig:"KEDA_HTTP_WATCH_LABEL" default:""`
18
24
// ProxyPort is the port that the public proxy should run on
19
25
ProxyPort int `envconfig:"KEDA_HTTP_PROXY_PORT" required:"true"`
20
26
// AdminPort is the port that the internal admin server should run on.
Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ import (
34
34
"github.com/kedacore/http-add-on/pkg/queue"
35
35
"github.com/kedacore/http-add-on/pkg/routing"
36
36
"github.com/kedacore/http-add-on/pkg/util"
37
+ v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
38
+ "k8s.io/apimachinery/pkg/labels"
37
39
)
38
40
39
41
var (
@@ -104,7 +106,22 @@ func main() {
104
106
105
107
queues := queue .NewMemory ()
106
108
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
+ } else {
117
+ labelSelector = labels .Everything ()
118
+ }
119
+
120
+ sharedInformerFactory := informers .NewSharedInformerFactoryWithOptions (httpCl , servingCfg .ConfigMapCacheRsyncPeriod ,
121
+ informers .WithTweakListOptions (func (options * v1.ListOptions ) {
122
+ options .LabelSelector = labelSelector .String ()
123
+ }),
124
+ )
108
125
routingTable , err := routing .NewTable (sharedInformerFactory , servingCfg .WatchNamespace , queues )
109
126
if err != nil {
110
127
setupLog .Error (err , "fetching routing table" )
You can’t perform that action at this time.
0 commit comments