Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: add label filtering for HTTPScaledObjects #1173

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions interceptor/config/serving.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ type Serving struct {
// WatchNamespace is the namespace to watch for new HTTPScaledObjects.
// Leave this empty to watch HTTPScaledObjects in all namespaces.
WatchNamespace string `envconfig:"KEDA_HTTP_WATCH_NAMESPACE" default:""`
// WatchLabel is the label to watch for new HTTPScaledObjects.
// Leave this empty to watch HTTPScaledObjects in all labels.
//
// Example:
// export KEDA_HTTP_WATCH_LABEL="scope=internal"
WatchLabel string `envconfig:"KEDA_HTTP_WATCH_LABEL" default:""`
// ProxyPort is the port that the public proxy should run on
ProxyPort int `envconfig:"KEDA_HTTP_PROXY_PORT" required:"true"`
// AdminPort is the port that the internal admin server should run on.
Expand Down
21 changes: 20 additions & 1 deletion interceptor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"github.com/kedacore/http-add-on/pkg/queue"
"github.com/kedacore/http-add-on/pkg/routing"
"github.com/kedacore/http-add-on/pkg/util"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)

var (
Expand Down Expand Up @@ -104,7 +106,24 @@ func main() {

queues := queue.NewMemory()

sharedInformerFactory := informers.NewSharedInformerFactory(httpCl, servingCfg.ConfigMapCacheRsyncPeriod)
var labelSelector labels.Selector
if servingCfg.WatchLabel != "" {
labelSelector, err = labels.Parse(servingCfg.WatchLabel)
if err != nil {
setupLog.Error(err, "invalid WatchLabel format")
os.Exit(1)
}
setupLog.Info("watching label", "label", servingCfg.WatchLabel)
} else {
labelSelector = labels.Everything()
setupLog.Info("watching all labels")
}

sharedInformerFactory := informers.NewSharedInformerFactoryWithOptions(httpCl, servingCfg.ConfigMapCacheRsyncPeriod,
informers.WithTweakListOptions(func(options *v1.ListOptions) {
options.LabelSelector = labelSelector.String()
}),
)
routingTable, err := routing.NewTable(sharedInformerFactory, servingCfg.WatchNamespace, queues)
if err != nil {
setupLog.Error(err, "fetching routing table")
Expand Down
Loading