kubernetes “Krew”错误:标志不能放在插件名称之前”

ua4mk5z4  于 2023-06-28  发布在  Kubernetes
关注(0)|答案(2)|浏览(112)

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

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/
然后,当我尝试执行任何命令时,这是结果:
错误:标志不能放在插件名称之前:--集群
例如:

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

ix0qys7i1#

为什么在运行kubectl之前先运行minikubein命令

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

atmip9wb

atmip9wb2#

我只是删除了minikube alias kubectl="minikube kubectl --"文档中建议的别名,并将kubectl直接安装在我的操作系统(Ubuntu 20.04)上:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"\n
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client

参考:https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

相关问题