admiraltyio / multicluster-controller

A Library for Building Hybrid and Multicloud Kubernetes Operators
https://admiralty.io
Other
248 stars 20 forks source link

Multiple Watches in Multiple Clusters #4

Open saahildhulla opened 3 years ago

saahildhulla commented 3 years ago

Hi there!

I'm trying to understand how to use multicluster-controller to set watches on resources in multiple clusters + multiple namespaces.

It seems like if I call WatchResourceReconcileObject multiple times in succession that the controller only takes the last one. Any help would be appreciated!

Ex.

    for _, c := range clients {
        log.Printf("Starting Service Watch over namespaces: %v\n with client %s", realizedConfig.Namespaces, c.name)
        if err := ctrl.WatchResourceReconcileObject(ctx, c.cluster, &v1.Service{}, controller.WatchOptions{Namespaces: realizedConfig.Namespaces}); err != nil {
            return nil, fmt.Errorf("cannot create Service watch in %s cluster: %w", c.name, err)
        }
    }