<p>I want to create a custom kubernetes resource with go. The application is deployed in the kubernetes cluster. I want to create e.g. the followng resource:</p>
<pre><code>    apiVersion: configuration.konghq.com/v1
    kind: KongPlugin
    metadata:
      name: add-response-header
    config:
      add:
        headers:
        - &quot;demo: injected-by-kong&quot;
    plugin: response-transformer
</code></pre>
<p>So far I always created the 'standard' resources e.g. a secret with the following code:</p>
<pre><code>     CreateSecret(name string, data map[string]string) error {
 confs, err := rest.InClusterConfig()
        if err != nil {
            panic(err)
        }
        clientset, err = kubernetes.NewForConfig(confs)
        i := clientset.CoreV1()
        if _, err := i.Secrets(namespace).Create(&amp;v1.Secret{
            TypeMeta:   metav1.TypeMeta{
                Kind:       &quot;Secret&quot;,
                APIVersion: &quot;v1&quot;,
            },
            ObjectMeta: metav1.ObjectMeta{
                Name:   name,
            },
            StringData: data,
            Type:       &quot;Opaque&quot;,
        }); err != nil {
            return err
        }
}
</code></pre>
<p>In addition I tried to get a resource with the following code:</p>
<pre><code>b, err := clientset.RESTClient().Get().Namespace(namespace).Resource(&quot;KongPlugin&quot;).DoRaw()
</code></pre>
<p>I get the following err:</p>
<pre><code>the server could not find the requested resource (get KongPlugin)
</code></pre>
<p>If I make a request at the command line <code>k get KongPlugin</code> I can see all the resources.</p>
<pre><code>NAME                PLUGIN-TYPE           AGE
add-proxy-headers   request-transformer   3h34m
</code></pre>
<p>So how can view the custom resoources?</p>

SamuelTJackson
<p>For <code>RESTClient</code> 👇🏼</p>
<blockquote>
<h2><code>Get:</code></h2>
</blockquote>
<p>You have to fully specify path to you custom resource.
Use <code>fluent</code> interface</p>
<pre><code>data, err := clientset.RESTClient().
        Get().
        AbsPath(&quot;/apis/&lt;api&gt;/&lt;version&gt;&quot;).
        Namespace(&quot;&lt;namespace&gt;&quot;).
        Resource(&quot;kongplugins&quot;).
        Name(&quot;kongplugin-sample&quot;).
        DoRaw(context.TODO())
</code></pre>
<p>or specify manually</p>
<pre><code>data, err := clientset.RESTClient().
        Get().
        AbsPath(&quot;/apis/&lt;api&gt;/&lt;version&gt;/namespaces/&lt;namespace&gt;/kongplugins/kongplugin-sample&quot;).
        DoRaw(context.TODO())
</code></pre>
<p>You can find <code>AbsPath</code> in <code>selfLink</code> of custom resource.</p>
<blockquote>
<h2><code>Create:</code></h2>
</blockquote>
<p>For example, you can <code>post</code> marshaled data use <code>AbsPath</code></p>
<pre><code>kongPlugin := &amp;KongPlugin{
        TypeMeta: metav1.TypeMeta{
            APIVersion: &quot;&lt;api&gt;/&lt;version&gt;&quot;,
            Kind:       &quot;KongPlugin&quot;,
        },
        ObjectMeta: metav1.ObjectMeta{
            Name:      &quot;kongplugin-sample&quot;,
            Namespace: &quot;&lt;namespace&gt;&quot;,
        },
        ...}}

body, err := json.Marshal(kongPlugin)

data, err := clientset.RESTClient().
        Post().
        AbsPath(&quot;/apis/&lt;api&gt;/&lt;version&gt;/namespaces/&lt;namespace&gt;/kongplugins&quot;).
        Body(body).
        DoRaw(context.TODO())
</code></pre>
<p>because <code>arg</code> of the method <code>Body(obj interface{})</code> is an empty interface, you can use different types of arguments according to documentation:
<a href="https://godoc.org/k8s.io/client-go/rest#Request.Body" rel="noreferrer">k8s.io/client-go/rest - func (*Request) Body</a></p>
