我有一个本地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/
然后,当我尝试执行任何命令时,结果如下:
错误:标记不能放在插件名之前:——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
我刚刚从minikubealias kubectl="minikube kubectl --"
删除了文档中建议的别名,并直接在我的操作系统(Ubuntu 20.04)上安装kubectl:
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/