Determine what resource was not found from “Error from server (NotFound): the server could not find the requested resource”

淺唱寂寞╮ 提交于 2021-02-18 10:36:06

问题


I'm running kubectl create -f notRelevantToThisQuestion.yml

The response I get is:

Error from server (NotFound): the server could not find the requested resource

Is there any way to determine which resource was requested that was not found?

kubectl get ns returns

NAME STATUS AGE
default Active 243d
kube-public Active 243d
kube-system Active 243d

This is not a cron job.
Client version 1.9
Server version 1.6

This is very similar to https://devops.stackexchange.com/questions/2956/how-do-i-get-kubernetes-to-work-when-i-get-an-error-the-server-could-not-find-t?rq=1 but my k8s cluster has been deployed correctly (everything's been working for almost a year, I'm adding a new pod now).


回答1:


To solve this downgrade the client or upgrade the server. In my case I've upgraded server (new minikube) but forget to upgrade client (kubectl) and end up with those versions.

$ kubectl version --short
Client Version: v1.9.0
Server Version: v1.14.1

When I'd upgraded client version (in this case to 1.14.2) then everything started to work again.

Instructions how to install (in your case upgrade) client are here https://kubernetes.io/docs/tasks/tools/install-kubectl




回答2:


The cause of problem in versions:

From documentation

a client should be skewed no more than one minor version from the master, but may lead the master by up to one minor version. For example, a v1.3 master should work with v1.1, v1.2, and v1.3 nodes, and should work with v1.2, v1.3, and v1.4 clients.




回答3:


From http://words.yuvi.in/post/kubectl-rbac/

Running kubectl create -f notRelevantToThisQuestion.yml -v=8 will print all the HTTP traffic (requests and responses!) in an easy to read way. In this way, one can identify which resource is not available from the http responses.




回答4:


I have the same error when trying to do a CD with Jenkins and Kubernetes. In the pipeline I excute kubectl create -f app-deployment.yml -v=8 This image show more information about the error:



来源:https://stackoverflow.com/questions/51180147/determine-what-resource-was-not-found-from-error-from-server-notfound-the-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!