Skip to content

Commit

Permalink
Add capability to watch multiple namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitt authored and Thomas Vitt committed May 12, 2022
1 parent 11c2681 commit 5dae4e1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
acceptV1Data = flag.Bool("accept-deprecated-v1-data", true, "Accept deprecated V1 data field.")
keyCutoffTime = flag.String("key-cutoff-time", "", "Create a new key if latest one is older than this cutoff time. RFC1123 format with numeric timezone expected.")
namespaceAll = flag.Bool("all-namespaces", true, "Scan all namespaces or only the current namespace (default=true).")
addNamespaces = flag.String("add-namespaces", "", "Comma-separated list of additional namespaces to be scanned. Use --all-namespaces=false with this option.")
labelSelector = flag.String("label-selector", "", "Label selector which can be used to filter sealed secrets.")

oldGCBehavior = flag.Bool("old-gc-behaviour", false, "Revert to old GC behavior where the controller deletes secrets instead of delegating that to k8s itself.")
Expand Down Expand Up @@ -212,6 +213,7 @@ func main2() error {
namespace := v1.NamespaceAll
if !*namespaceAll {
namespace = myNamespace()
log.Printf("Starting informer for namespace: %s\n", namespace)
}

var tweakopts func(*metav1.ListOptions) = nil
Expand All @@ -230,6 +232,19 @@ func main2() error {
defer close(stop)

go controller.Run(stop)

if !*namespaceAll && *addNamespaces != "" {
namespaces := strings.Split(*addNamespaces, ",")
var inf ssinformers.SharedInformerFactory
var ctlr *Controller

for _, ns := range namespaces {
inf = ssinformers.NewFilteredSharedInformerFactory(ssclientset, 0, ns, tweakopts)
ctlr = NewController(clientset, ssclientset, inf, keyRegistry)
log.Printf("Starting new informer for namespace: %s\n", ns)
go ctlr.Run(stop)
}
}

cp := func() ([]*x509.Certificate, error) {
cert, err := keyRegistry.getCert()
Expand Down

0 comments on commit 5dae4e1

Please sign in to comment.