NimbleArchitect / kubectl-ice

Kubectl-ice is an open-source tool for Kubernetes users to monitor and optimize container resource usage. Features include usage breakdowns for pods and containers, making scaling and optimization easier. The tool is compatible with major cloud providers and is actively developed by a community of contributors
Apache License 2.0
244 stars 9 forks source link

failed to create clientset #8

Closed luciferhs closed 1 year ago

luciferhs commented 2 years ago

[root@mexo-relay ~]# kubectl-ice cpu -A failed to create clientset: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"

NimbleArchitect commented 2 years ago

that error happens when the code is unable to create a clientset config in memory, three questions spring to mind

dmitry-mightydevops commented 2 years ago

so I just faced the same issue by updating kubectl. It seems it is related:

✗  kubectl version                          
Client Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.6-eks-7d68063", GitCommit:"f24e667e49fb137336f7b064dba897beed639bad", GitTreeState:"clean", BuildDate:"2022-02-23T19:32:14Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.9-eks-a64ea69", GitCommit:"540410f9a2e24b7a2a870ebfacb3212744b5f878", GitTreeState:"clean", BuildDate:"2022-05-12T19:15:31Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

➜ k ice cpu --match 'used>0' --sort '!USED'
failed to create clientset: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1"

at the same time kubectl works as expected:

➜ kubectl get pods                                                                                                             
No resources found in default namespace.

to fix you need to update to latest aws cli

 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install --update

➜ k ice cpu --match 'used>0' --sort '!USED'
no pods found in default namespace
dmitry-mightydevops commented 2 years ago

and don't forget to do after you update aws cli

✗  aws eks --region us-east-1 update-kubeconfig --name project-staging-eks
Updated context arn:aws:eks:us-east-1:xxxx:cluster/project-staging-eks in /home/dmitry/.kube/config
NimbleArchitect commented 1 year ago

moved answer to faq page also linked it back here

https://nimblearchitect.github.io/kubectl-ice/faq/#failed-to-create-clientset