<p>Via the CLI, I can use <code>kubectl api-resources --namespaced=false</code> to list all available cluster-scoped resources in a cluster.</p>
<p>I am writing a custom operator with the <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">Python Kubernetes Client API</a>, however I can't seem to find anything in the API that allows me to do this.</p>
<p>The closest I have found is the <a href="https://github.com/kubernetes-client/python/blob/master/examples/api_discovery.py" rel="nofollow noreferrer">following code</a>, which was included as an example in the repository:</p>
<pre class="lang-py prettyprint-override"><code>from kubernetes import client, config


def main():
    # Configs can be set in Configuration class directly or using helper
    # utility. If no argument provided, the config will be loaded from
    # default location.
    config.load_kube_config()

    print(&quot;Supported APIs (* is preferred version):&quot;)
    print(&quot;%-40s %s&quot; %
          (&quot;core&quot;, &quot;,&quot;.join(client.CoreApi().get_api_versions().versions)))
    for api in client.ApisApi().get_api_versions().groups:
        versions = []
        for v in api.versions:
            name = &quot;&quot;
            if v.version == api.preferred_version.version and len(
                    api.versions) &gt; 1:
                name += &quot;*&quot;
            name += v.version
            versions.append(name)
        print(&quot;%-40s %s&quot; % (api.name, &quot;,&quot;.join(versions)))


if __name__ == '__main__':
    main()
</code></pre>
<p>Unfortunately, <code>client.ApisApi()</code> doesn't have a <code>get_api_resources()</code> option.</p>
<p>Does anybody know of a way that I can list all the api-resources?</p>

Anthony Seager
<p>You can get Api Resources using <code>AppsV1Api.get_api_resources()</code>.</p>
<p><a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md#get_api_resources" rel="nofollow noreferrer">https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md#get_api_resources</a></p>
