I've started learning kubernetes using docker in windows server 2016. I've already tested using minikube in my local machine successfully. but this time i want to start it through docker. but unfortunately it was failed with below error:
PS C:\WINDOWS\system32> install-kubectl.ps1 -Downloadlocation $HOME/.kube
==>Getting download link from https://kubernetes.io/docs/tasks/tools/install-kub
ectl/
==>analyzing Downloadlink
==>starting Download from https://storage.googleapis.com/kubernetes-release/relea
se/v1.13.0/bin/windows/amd64/kubectl.exe using Bitstransfer
==>starting 'C:\Users\Siva_Sankara_Rao_Bac\.kube\kubectl.exe version'
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.0", GitComm
it:"ddf47ac13c1a9483ea035a79cd7c10005ff21a6d", GitTreeState:"clean", BuildDate:"2
018-12-03T21:04:45Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"windows/amd6
4"}
kubectl.exe : Unable to connect to the server: dial tcp [::1]:8080: connectex:
No connection could be made because the target machine actively refused it.
At C:\Users\Siva_Sankara_Rao_Bac\Documents\WindowsPowerShell\Scripts\install-kub
ectl.ps1:47 char:1
+ .$Downloadfile version
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Unable to conne...ely refused it.:
String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
i've tried to figured it out but my knowledge not able get it even from google .tried many ways as instructed in different websites. but no luck.
kubectl.exe : Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
You see this error because when you run kubectl version
, it shows you client version (kubectl binary) first and then version of your Kubernetes cluster. It tries to connect to the cluster using current context in the .kube/config
.
It looks like you don't have a cluster or you don't have it configured in $HOME/.kube/config
Without correct configuration kubectl
uses default values like localhost:8080
and as you obviously don't have kube-apiserver
running on that IPaddress:port
, kubectl fails to get the Kubernetes cluster version and print the connection error message.
If you activated docker-for-desktop cluster after using minikube, you may need to switch kubectl
context in the docker icon context menu.
The bottom line: There is nothing wrong with kubectl
or its installation on your computer. To fix the issue, you need to create a cluster and put the correct connection configuration in the kubectl
config file.