Watching for Istio ServiceEntry resources via K8s API

Hi all,

I would like to make use of K8s Informer API functionality to watch for Istio ServiceEntries objects and to patch the resource manifest via some custom logic. Are there any examples on how to get this done for Istio CRDs? I’ve tried the below code but unfortunately it’s not working as expected.

    watchlist := cache.NewListWatchFromClient(
        clientset.CoreV1().RESTClient(),
        "serviceentries.networking.istio.io",
        v1.NamespaceAll,
        fields.Everything(),
    )

    _, controller := cache.NewInformer(
        watchlist,
        &v1alpha3.ServiceEntry{},
        0, //Duration is int64
        cache.ResourceEventHandlerFuncs{
            AddFunc: func(obj interface{}) {
                fmt.Printf("service entry added: %s \n", obj)
            },
            DeleteFunc: func(obj interface{}) {
                fmt.Printf("service entry deleted: %s \n", obj)
            },
            UpdateFunc: func(oldObj, newObj interface{}) {
                fmt.Printf("service entry changed \n")
            },
        },
    )

I get the following response:

E0824 12:50:56.625283   81045 reflector.go:178] pkg/mod/k8s.io/client-go@v0.18.1/tools/cache/reflector.go:125: Failed to list *v1alpha3.ServiceEntry: the server could not find the requested resource