0

I'm using kubernetes python client library to list all ingresses in a namespace. I'm using the api NetworkingV1Api(). When i run the code, its throwing the error "AttributeError: 'NetworkingV1Api' object has no attribute 'list_namespaced_ingress'"

from kubernetes import client, config

config.load_kube_config(config_file=os.environ.get("KUBECONFIG",'my-cluster.config'),context=os.environ.get("KUBECONTEXT"))

v1=client.NetworkingV1Api()
ingress_list=v1.list_namespaced_ingress(namespace=ns1)
print(ingress_list)

Can someone please help on this issue. I'm able to execute other api resources using this client.

I'have tried with ExtensionsV1beta1Api() and CoreV1Api(), but still no luck.

  • Are you on an older version of the kubernetes python library, perhaps? – Botje Aug 10 '23 at 08:04
  • @botje, could you please help me in checking the version, what is the command should i use to check. the python version was 3.9.16 – Venu Madhav Aug 10 '23 at 11:09
  • That answer depends on the package manager you're using. If you used pip it could be as simple as `pip freeze`. – Botje Aug 10 '23 at 11:15
  • Thanks, seems earlier i just used ```pip install kubernetes``` and it installed some older version. Now, i have used ```pip install kubernetes==27.2.0```. Which solved the issue. Thanks @botje – Venu Madhav Aug 10 '23 at 11:31

0 Answers0