<p>I'm currently using the Python APIs for Kubernetes and I have to:</p>
<ul>
<li><p>Retrieve the instance of a custom resource name <code>FADepl</code>.</p>
</li>
<li><p>Edit the value of that instance.</p>
</li>
</ul>
<p>In the terminal, I would simply list all <code>FADepls</code> with <code>kubectl get fadepl</code> and then edit the right one using <code>kubectl edit fadepl &lt;fadepl_name&gt;</code>. I checked the <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md" rel="nofollow noreferrer">K8s APIs for Python</a> but I can't find what I need. Is it something I can do with the APIs?</p>
<p>Thank you in advance!</p>

texdade
<p>You can use <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CustomObjectsApi.md#list_cluster_custom_object" rel="nofollow noreferrer">list_cluster_custom_object</a> method from <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CustomObjectsApi.md#kubernetesclientcustomobjectsapi" rel="nofollow noreferrer">kubernetes.client.CustomObjectsApi</a>.</p>
<p>Let's say that I need to get all calico <a href="https://projectcalico.docs.tigera.io/reference/resources/networkset" rel="nofollow noreferrer">globalnetworksets</a> instances which are a CRD from calico project.</p>
<p>So first, we need to retrieve some crd data using kubectl as follows:</p>
<pre class="lang-bash prettyprint-override"><code># get api group, version and plural

&gt; kubectl api-resources -o wide | grep globalnetworkset
    globalnetworksets  crd.projectcalico.org/v1  false  GlobalNetworkSet
     ---------------    -------------------  --
        `plural`             api group       v
</code></pre>
<p>With that in mind, we implement <code>list_cluster_custom_object</code></p>
<pre class="lang-py prettyprint-override"><code>from kubernetes.client import CustomObjectsApi

group = &quot;crd.projectcalico.org&quot;
v = &quot;v1&quot;
plural = &quot;globalnetworksets&quot;

global_network_sets = CustomObjectsApi.list_cluster_custom_object(group, v, plural)

</code></pre>
