I am trying to learn Kubernetes and so I installed Minikube on my local Windows 10 Home machine and then I tried installing the kubectl. However so far I have been unsuccessful in getting it right. So this what I have done so far: Downloaded the kubectl.exe file from https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/windows/amd64/kubectl.exe
Then I added the path of this exe in the path environment variable
as shown below:
However this didn't work when I executed kubectl version
on the command prompt or even on pwoershell (in admin mode)
Next I tried using the curl command as given in the docs - https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-with-curl-on-windows
However that too didn't work as shown below:
Upon searching for answers to fix the issue, I stumbled upon this StackOverfow question which explained how to create a .kube
config folder because it didn't exist on my local machine. I followed the instructions, but that too failed.
So right now I am completely out of ideas and not sure whats the issue here. FYI, I was able to install everything in a breeze on my Mac, however Windows is just acting crazy.
Any help would be really helpful.
As user @paltaa mentioned:
did you do a
minikube start
? – paltaa 2 days ago
The fact that you did not start the minikube
is the most probable cause why you are getting this error.
Additionally this error message shows when the minikube
is stopped as stopping will change the current-context
inside the config
file.
There is no need to create a config
file inside of a .kube
directory as the minikube start
will create appropriate files and directories for you automatically.
If you run minikube start
command successfully you should get below message at the end of configuration process which will indicate that the kubectl
is set for minikube
automatically.
Done! kubectl is not configured to use "minikube"
Additionally if you invoke command $ kubectl config
you will get more information how kubectl
is looking for configuration files:
The loading order follows these rules:
1. If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes
place.
2. If $KUBECONFIG environment variable is set, then it is used as a list of paths (normal path delimiting rules for
your system). These paths are merged. When a value is modified, it is modified in the file that defines the stanza. When
a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the
last file in the list.
3. Otherwise, ${HOME}/.kube/config is used and no merging takes place.
Please take a special look on part:
- Otherwise, ${HOME}/.kube/config is used
Even if you do not set the KUBECONFIG
environment variable kubectl
will default to $USER_DIRECTORY
(for example C:\Users\yoda\
.
If for some reason your cluster is running and files got deleted/corrupted you can:
minikube stop
minikube start
which will recreate a .kube/config
Steps for running minikube
on Windows in this case could be:
kubectl
directory to Windows environment variables$ minikube start --vm-driver=virtualbox
$ kubectl get nodes
.Please let me know if this helped.