No connection could be made because the target machine actively refused it. "Kubernetes on Docker for Windows"

7/10/2018

I have installed the Edge version of Docker for Windows 18.05.0-ce (Windows 10 Hyper-V) and enabled Kubernetes afterwards.
On my other machine a kubectl context was created automatically, but on this new machine it was not.

> kubectl config get-contexts
CURRENT   NAME      CLUSTER   AUTHINFO   NAMESPACE
> kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:17:39Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

Can i some how make Docker for Windows create the context?
Or can I set it up manually?
I am a little unsure how to get the infomation needed for the kubectl config set-context command.

I can run docker containers outside of Kubernetes.
I see the Kubernetes containers running inside Docker.

> docker ps
CONTAINER ID        IMAGE                            COMMAND
8285ca0dd57a        353b8f1d102e                     "kube-scheduler --ad…"
3b25fdb0b7a6        40c8d10b2d11                     "kube-controller-man…"
e81db90fa68e        e03746fe22c3                     "kube-apiserver --ad…"
2f19e723e0eb        80cc5ea4b547                     "/kube-dns --domain=…"
etc...
-- KasperT
docker
docker-for-windows
kubernetes

2 Answers

7/10/2018

There is an issue with docker for windows when the HOMEDRIVE is set my a corporate policy.

If you set the $KUBECONFIG environment variable to C:\Users\my_username\.kube\config (make sure the $HOME environment variables expands, don't use $HOME itself.) It should work.

Further info: https://github.com/docker/for-win/issues/1651

-- jaxxstorm
Source: StackOverflow

7/10/2018

I found that Docker for Windows correctly updated my kubectl config file, but on Windows 10 Enterprise there is no environment variable called "HOME".

So kubectl cant find the config file, C:\users\{userid}\.kube\config

Adding environment variable HOME=C:\users\{userid} solved the issue on my machine.

See: https://github.com/docker/for-win/issues/2066

-- KasperT
Source: StackOverflow