为什么简单的kubectl(1.16)运行显示错误?

时间:2019-12-01 23:52:31

标签: kubernetes kubectl

kubectl版本

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-18T14:56:51Z", GoVersion:"go1.12.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

错误 当我运行kubectl run时,会发生错误。

$ kubectl run nginx --image=nginx
WARNING: New generator "deployment/apps.v1" specified, but it isn't available. Falling back to "run/v1".
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
error: no matches for kind "Deployment" in version "apps/v1"

这似乎是由新版本(1.16.x)引起的,不是吗? 据我搜索,甚至官方文件也没有明确提及与此情况相关的内容。我该如何使用kubectl run

2 个答案:

答案 0 :(得分:0)

尝试

kubectl create deployment --image nginx my-nginx

答案 1 :(得分:0)

根据kubectl Usage Conventions的建议,

  

指定--generator标志可在您固定到特定行为时   使用基于生成器的命令,例如kubectl run或kubectl暴露

改为使用kubectl run --generator=run-pod/v1 nginnnnnnx --image nginx

也@soltysh describes well enough为什么最好使用kubectl create而不是kubectl run