get all the proper namespaces and ingressroutes with the python k8's api client library


I have the following command line below. It gives me the namespaces and ingressroutes names (see the Example below)

kubectl --context mlf-eks-dev get --all-namespaces ingressroutes


NAMESPACE                       NAME                                                           AGE
aberdeentotalyes               aberdeentotalgeyes-yesgepi                                      98d

I"m trying to replicate the kubetl command line above through my python code, using the python client for kubernetes but I miss on the option, on how to get the ingressroutes.

#My python code
from kubernetes import client, config

# Configs can be set in Configuration class directly or using helper utility

v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
    print("%s\t%s" % (i.metadata.namespace,

The results are below

wwwpaulolo   ci-job-backup-2kt6f
wwwpaulolo   wwwpaulolo-maowordpress-7dddccf44b-ftpbq
wwwvhugo        ci-job-backup-dz5hs
wwwvhugo        wwwvhua-maowordpress-5f7bdfdccd-v7kcx

I have the namespaces but not the ingressroutes, as I don't know how can I get it.

Question is what is the option to have the ingressroutes, please?

Any helps are more than welcomed.


-- Andy K

2 Answers


After a careful reading of the documentation of the existing APIs for ingressroutes, I found none that can be used, all of them are still in beta as Ingressroutes is not a native components of Kubernetes.

I also asked on Slack's Kubernetes, on the Kubernetes client channel.

Alan C on Kubernetes's slack, gave me that answer:

There's no class for ingressroutes. You can use the dynamic client to support arbitrary resource types (see link)

My solution is to use the python library subprocess to run the kubectl command line.

-- Andy K
Source: StackOverflow


did you try CustomObjectsApi?

from kubernetes import client, config
api = client.CustomObjectsApi()
dir(api) # check for list_cluster_custom_object 

#example below api will list all issuers in the cluster. 
#issuer is custom resource of
-- Sandeep kumar singh
Source: StackOverflow