<p>I am trying to create a kubernetes Custom Resource Definition (named <code>Block</code>) but keep hitting the following error: </p>

<pre><code>Failed to list *v1alpha1.Block: the server could 
not find the requested resource (get 
blocks.kubechain.com).
</code></pre>

<p>This issue is raised from a call to <code>List</code> on a Controller for this CRD:</p>

<pre><code>indexer, controller := cache.NewIndexerInformer(
        &amp;cache.ListWatch{
            ListFunc: func(lo metav1.ListOptions) (result k8sruntime.Object, err error) {
                return clientSet.Block(ns).List(lo)
            },
            WatchFunc: func(lo metav1.ListOptions) (watch.Interface, error) {
                return clientSet.Block(ns).Watch(lo)
            },
        },
        &amp;v1alpha1.Block{},
        1*time.Minute,
        cache.ResourceEventHandlerFuncs{},
        cache.Indexers{},
    )
</code></pre>

<p>For some context here is the <code>register.go</code> file where I register the above resourced to the a scheme builder:</p>

<pre><code>// GroupName is the api prefix.
const GroupName = "kubechain.com"

// GroupVersion is the version of the api.
const GroupVersion = "v1alpha1"

// SchemeGroupVersion is the group version object.
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}

var (
    // SchemeBuilder adds the new CRDs Block and Blockchain.
    SchemeBuilder = runtime.NewSchemeBuilder(AddKnownTypes)
    // AddToScheme uses SchemeBuilder to add new CRDs.
    AddToScheme = SchemeBuilder.AddToScheme
)

// AddKnownTypes .
func AddKnownTypes(scheme *runtime.Scheme) error {
    scheme.AddKnownTypes(SchemeGroupVersion,
        &amp;Block{},
        &amp;BlockList{},
    )
    metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    return nil
}
</code></pre>

<p>And here is the <code>scheme.go</code> file where I actually run <code>AddToScheme</code> from the former file:</p>

<pre><code>var Scheme = runtime.NewScheme()
var Codecs = serializer.NewCodecFactory(Scheme)
var ParameterCodec = runtime.NewParameterCodec(Scheme)
var localSchemeBuilder = runtime.SchemeBuilder{
    v1alpha1.AddToScheme,
}

var AddToScheme = localSchemeBuilder.AddToScheme

func init() {
    metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"})
    if err := AddToScheme(Scheme); err != nil {
        panic(err)
    }
}
</code></pre>

<p>Can anyone share some information as to what I am doing wrong here??</p>

<p>This work is following <a href="https://www.martin-helmich.de/en/blog/kubernetes-crd-client.html" rel="noreferrer">this</a> blog post.</p>

Nimrodshn
<p>I have seen similar error. It was RBAC issue. But the error message was misleading.</p>

<p>If your cluster has RBAC enabled, make sure your controller has <code>get</code>,<code>list</code> permission for <code>blocks.kubechain.com</code> resource.</p>
