admiraltyio / multicluster-controller

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

Watch in specific namespace #2

Closed allamand closed 4 years ago

allamand commented 5 years ago

Hello,

I'm trying to understand how multicluster-controller works and I would like to to configure a Watch to a specific namespace. I tried to update this part specifiying a namespace:

    p := v1.Pod{
        TypeMeta: metav1.TypeMeta{
            Kind:       "Pod",
            APIVersion: "v1",
        },
        ObjectMeta: metav1.ObjectMeta{
            Namespace: namespace,
        },
    }
    if err := co.WatchResourceReconcileObject(cluster1, &p, controller.WatchOptions{}); err != nil {
        return nil, fmt.Errorf("setting up Pod watch in cluster1 cluster: %v", err)
    }

But at runtime, the watch show me all pods cluster-wide..

How can I configure it to watch a namespace correctly ?

thanks

sébastien

adrienjt commented 4 years ago

v0.2.0 adds watch options.

In your case, you'd fill in the new Namespace field in WatchOptions.