yogeshkk / K8sPurger

Hunt Unused Resources In Kubernetes
Apache License 2.0
254 stars 27 forks source link

Failed to run #17

Closed shariqmus closed 2 years ago

shariqmus commented 2 years ago

python K8sPurger.py

This script is created to find unused resource in Kubernetes

Not able to read Kubernetes cluster check Kubeconfig Traceback (most recent call last): File "/Users/Shariq.Mustquim/DevOps/poc/k8s-misc/K8sPurger/K8sPurger.py", line 25, in main v1beta1Api = client.ExtensionsV1beta1Api() AttributeError: module 'kubernetes.client' has no attribute 'ExtensionsV1beta1Api'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/Shariq.Mustquim/DevOps/poc/k8s-misc/K8sPurger/K8sPurger.py", line 332, in main("standalone") File "/Users/Shariq.Mustquim/DevOps/poc/k8s-misc/K8sPurger/K8sPurger.py", line 30, in main raise RuntimeError(e) RuntimeError: module 'kubernetes.client' has no attribute 'ExtensionsV1beta1Api'

yogeshkk commented 2 years ago

Hello @shariqmus I am guessing your kubernetes version is bit old. can you please let me know which version you are on.

also can you try docker image or k8s deployment and let me know that work or not.

shariqmus commented 2 years ago

Hi yogesh, thanks for the response, kubernetes version is 1.20.7 on AKS I will try with the docker image and report back any finding

yogeshkk commented 2 years ago

@shariqmus,

Kubernetes version is ok. Apart from running in K8S you can do following.

Install latest dependency by pip3 install -r requirements.txt and make sure you set kubectl context. you can verify that by running kubectl get pod

thoefkens commented 2 years ago

@yogeshkk I am facing the same error.. running v1.21.5 as server version and kubectl as v1.23.5. Installed requirements as indicated with pip3, also the kubecontext is set. Any other ideas?

yogeshkk commented 2 years ago

Hello @thoefkens,

Can you check you have correct version of kuberntes python client installed. The error mean that there is mismatch between kubernetes version and kubernetes-python version. (likely lower kubernetes-client version in this case)

https://github.com/kubernetes-client/python#compatibility

alternatively you can try docker image

jessequinn commented 2 years ago

easy fix. set the specific version of kubernetes kubernetes==21.7.0 for 1.21 support. tested, and proven.

yogeshkk commented 2 years ago

Correct @jessequinn.

If have issue please check if you are using correct version of client library or pin as suggested by @jessequinn.

Marking issue as closed