Search code examples
kuberneteswindows-10kubectlminikube

`kubectl` not found. If you need it, try: 'minikube kubectl -- get pods -A'


I installed minikube in Windows 10 . I am able to start minikube

**C:\WINDOWS\system32>minikube start
* minikube v1.15.1 on Microsoft Windows 10 Pro 10.0.18363 Build 18363
* Using the hyperv driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Restarting existing hyperv VM for "minikube" ...
* Preparing Kubernetes v1.19.4 on Docker 19.03.13 ...
* Verifying Kubernetes components...
* Enabled addons: storage-provisioner, default-storageclass
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default**

But there is a warning in above output ( 2nd last line ) says kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'

After that I executed this command too minikube kubectl -- get pods -A

Still getting below error while trying kubectl

C:\WINDOWS\system32>kubectl
'kubectl' is not recognized as an internal or external command,
operable program or batch file.

Solution

  • Minikube installs kubectl inside of itself.

    So to use the kubectl which you installed via minikube, you have to prepend the command arguments with minikube kubectl --. For example:

    # the same as `kubectl version --client`
    minikube kubectl -- version --client
    

    For convenience, you may want to add an alias in your shell configuration.

    Source: https://minikube.sigs.k8s.io/docs/handbook/kubectl/