<p>This golang code works well:</p>
<pre><code>    topics := &amp;kafka.KafkaTopicList{}
    d, err := clientSet.RESTClient().Get().AbsPath(&quot;/apis/kafka.strimzi.io/v1beta2/kafkatopics&quot;).DoRaw(context.TODO())
    if err != nil {
        panic(err.Error())
    }
</code></pre>
<p>However I'd like to get the <code>kafkatopics</code> custom resources only for a given namespace, is there a way to do this using <code>client-go</code> api? For information, using <code>clientSet.RESTClient().Get().Namespace(&quot;&lt;my-namespace&gt;&quot;)</code> returns the following error message: &quot;the server could not find the requested resource&quot;</p>

Fabrice Jammes
<p>Try:</p>
<pre class="lang-golang prettyprint-override"><code>group := &quot;kafka.strimzi.io&quot;
version := &quot;v1beta2&quot;
plural := &quot;kafkatopics&quot;

namespace := &quot;...&quot;

d, err := clientSet.RESTClient().Get().AbsPath(
    fmt.Sprintf(&quot;/apis/%s/%s/namespaces/%s/%s&quot;,
        group,
        version,
        namespace,
        plural,
    ).DoRaw(context.TODO())
if err != nil {
    panic(err.Error())
}
</code></pre>
<p>I think using CRDs, <code>client-go</code>'s <a href="https://pkg.go.dev/k8s.io/client-go@v0.28.0/rest#Request.Namespace" rel="nofollow noreferrer"><code>Namespace</code></a> method incorrectly appends <code>namespace/{namespace}</code> into the request URL with CRDs.</p>
<p>You want:</p>
<pre><code>/apis/{group}/{version}/namespaces/{namespace}/{plural}
</code></pre>
<p>Using <code>Namespace</code>, you get:</p>
<pre><code>/apis/{group}/{version}/{plural}/namespaces/{namespace}
</code></pre>
<p>You can prove this to yourself with:</p>
<pre class="lang-golang prettyprint-override"><code>log.Println(restClient.Get().Namespace(namespace).AbsPath(
    fmt.Sprintf(&quot;/apis/%s/%s/%s&quot;,
        group,
        version,
        plural,
    ),
).URL().String())
</code></pre>
