Problem with Krew “Error: flags cannot be placed before plugin name”

Problem with Krew “Error: flags cannot be placed before plugin name”

我有一个带有 kubectl 的本地 minikube 集群(版本:v1.21.0):

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"132a687512d7fb058d0f5890f07d4121b3f0a2e2", GitTreeState:"clean", BuildDate:"2021-05-12T12:40:09Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}

Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"132a687512d7fb058d0f5890f07d4121b3f0a2e2", GitTreeState:"clean", BuildDate:"2021-05-12T12:32:49Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"} 

我按照文档安装了krew:https://krew.sigs.k8s.io/docs/user-guide/setup/install/

然后,当我尝试执行任何命令时,结果如下:

Error: flags cannot be placed before plugin name: --cluster

例如:

minikube kubectl krew version
Error: flags cannot be placed before plugin name: --cluster

为什么你是 运行 minikubekubectl

之前的命令
minikube kubectl krew version

您可以通过此命令设置和使用K8s的上下文

kubectl config use-context CONTEXT_NAME

只有使用 kubectl 才能访问 Krew 并安装插件

kubectl krew install access-matrix

例子

kubectl access-matrix

阅读更多内容:https://krew.sigs.k8s.io/docs/user-guide/quickstart/

https://github.com/kubernetes/kubectl/issues/884