List all resources in a namespace using the Kubernetes python client List all resources in a namespace using the Kubernetes python client kubernetes kubernetes

List all resources in a namespace using the Kubernetes python client


Maybe this is what you were looking for:

from kubernetes import client, config# Configs can be set in Configuration class directly or using helper utilityconfig.load_kube_config()v1 = client.CoreV1Api()for api in client.ApisApi().get_api_versions().groups:    versions = []    for v in api.versions:        name = ""        if v.version == api.preferred_version.version and len(                api.versions) > 1:            name += "*"        name += v.version        versions.append(name)    print("%-40s %s" % (api.name, ",".join(versions)))

Taken from here: https://github.com/kubernetes-client/python/blob/master/examples/api_discovery.py