<p>I have few CRDs, but I am not exactly sure how to query kube-apiserver  to get list of CRs. Can anyone please provide any sample code?</p>

<p>my sample code for an out of cluster config</p>
<pre><code>    var kubeconfig *string
    kubeconfig = flag.String(&quot;kubeconfig&quot;, &quot;./config&quot;, &quot;(optional) relative path to the kubeconfig file&quot;)
    flag.Parse()

    // kubernetes config loaded from ./config or whatever the flag was set to
    config, err := clientcmd.BuildConfigFromFlags(&quot;&quot;, *kubeconfig)
    if err != nil {
        panic(err)
    }

    // instantiate our client with config
    clientset, err := kubernetes.NewForConfig(config)
    if err != nil {
        panic(err)
    }

    // get a list of our CRs
    pl := PingerList{}
    d, err := clientset.RESTClient().Get().AbsPath(&quot;/apis/pinger.hel.lo/v1/pingers&quot;).DoRaw(context.TODO())
    if err != nil {
        panic(err)
    }
    if err := json.Unmarshal(d, &amp;pl); err != nil {
        panic(err)
    }
</code></pre>
<p>PingerList{} is an object generated from Kubebuilder that I unmarshal to later in the code. However, you could just straight up <code>println(string(d))</code> to get that json.</p>
<p>The components in the AbsPath() are <code>&quot;/apis/group/verison/plural version of resource name&quot;</code></p>
<p>if you're using minikube, you can get the config file with <code>kubectl config view</code></p>
<p>Kubernetes-related imports are the following</p>
<pre><code>&quot;k8s.io/client-go/tools/clientcmd&quot;
&quot;k8s.io/client-go/kubernetes&quot;
</code></pre>
