// Package router — NSWatcher for multi-tenant mode. // // Listens for Namespaces labeled fission.io/managed=true and calls // HTTPTriggerSet.AddNamespace so the router picks up HTTPTriggers and // Functions in tenant namespaces without a restart. package router import ( "context" "go.uber.org/zap" "k8s.io/client-go/kubernetes" "github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils/manager" ) // StartNSWatcher registers a Kubernetes Namespace Informer for the router. // Whenever a Namespace with label fission.io/managed=true appears (or is relabeled), // the router immediately subscribes to HTTPTriggers and Functions in that namespace. func StartNSWatcher( ctx context.Context, logger *zap.Logger, kubeClient kubernetes.Interface, ts *HTTPTriggerSet, mgr manager.Interface, ) { _, handlers, err := utils.PrepareManagedNamespaceWatcher(ctx, logger, "router.NSWatcher", utils.DefaultNSResolver().Snapshot(), utils.NamespaceRemovalStrategyTrackOnly, NewNamespaceSubscriber(ts, mgr)) if err != nil { logger.Error("router.NSWatcher: BootstrapAndDispatch failed", zap.Error(err)) } utils.StartManagedNamespaceWatcher(ctx, logger, "router.NSWatcher", kubeClient, mgr, handlers) }