Search code examples
kuberneteskubectlminikube

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


I have a local minikube cluster (version: v1.21.0) with 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"} 

I installed krew according to the documentation: https://krew.sigs.k8s.io/docs/user-guide/setup/install/

Then, when I try to execute any command this is the result:

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

For example:

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

Solution

  • Why you are running the minikube in command before the kubectl

    minikube kubectl krew version
    

    You can set and use the context of K8s using this command

    kubectl config use-context CONTEXT_NAME
    

    Using the kubectl only you can access the Krew and install the plugins

    kubectl krew install access-matrix
    

    example

    kubectl access-matrix
    

    Read more at : https://krew.sigs.k8s.io/docs/user-guide/quickstart/

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