Kubernetes connection refused on port 8080 - Windows 10 - cmd

I have following error on Windows10 after installing kubectl via
choco install kubernetes-cli:
PowerShell
PS C:\Users\userA> kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", 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.
Cmd
C:\Users\userA>kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", 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.
I have created .kube folder (C:\Users\userA\.kube) and inside of it an empty config file
I set windows environment variable:
Variable_name: KUBECONFIG
value: C:\Users\userA\.kube\config
EDIT: I tested it with running minikube:

You need to start the server first, with:
minikube start
Edit: As op tries to use hyper-v the following command tells minikube to use hyper-v
minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"
To get this workling it is also neccessary to set a virtual switch named "Primary Virtual Switch" in hyper-v.

I've figured it out myself - on Windows 10
Hyper-V should be turn on if you are using Docker desktop but for minikube it should be turn off.
When i had turned off Hyper-V and restarted my PC - then minikube start worked fine.

Related

Can't run kubectl in docker container from a host machine installed Minikube "The connection to the server 127.0.0.1:32768 was refused"

I want to have a container that can access and run kubectl command on my host machine. Here is what I have:
I have installed Kubernetes and Minikube on my host machine.
I used this docker container: helm-kubectl link
This is the command I run my docker:
docker run -it -v ~/.kube:/root/.kube -v ~/.minikube:/Users/xxxx/.minikube dtzar/helm-kubectl
Inside the container, when I checked the cluster, I can see the context has loaded my minikube, However, I can't run another kubectl command due to the reason "The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?".
bash-5.0# kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-desktop docker-desktop docker-desktop
docker-for-desktop docker-desktop docker-desktop
* minikube minikube minikube
bash-5.0# kubectl get all
The connection to the server 127.0.0.1:32768 was refused - did you specify the right host or port?
I have checked my Kubenetes config at ~/.kube and the port is 32768.
- cluster:
certificate-authority: /Users/xxx/.minikube/ca.crt
server: https://127.0.0.1:32768
name: minikube
I have tried port -p 32768 or --expose 32768 but no luck. So anyone can help this?
Thanks zerkms! It works with --network host

Minikube and non-default NodePorts

I'm trying to start my dockerized application in a pod with a StatefulSet. The application uses around 20 ports, that are known by other services, so I'd like to expose them on the same port number as before the docker/k8s. For this I added port mappings in the service.yaml file like this:
- port: 8080
targetPort: 8080
nodePort: 8080
protocol: TCP
name: serverpool1
- port: 8081
targetPort: 8081
nodePort: 8081
protocol: TCP
name: serverpool2
To make this work I need to be able to use nodePorts not in the default range. For what I have seen it should work like this:
minikube start --extra-config=apiserver.ServiceNodePortRange=5000-46000
The issue is that if I have the --extra-config param, the minikube does not start, but gives an error:
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
E0904 09:18:24.862606 28110 start.go:305] Error restarting cluster: restarting kube-proxy: waiting for kube-proxy to be up for configmap update: timed out waiting for the condition
Without the --extra-config parameter it starts normally, but I'm not able to have the lower ports.
I have a Mac with High Sierra, I use VirtualBox as VM, I have minikube version v0.28.2 and kubectl version:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-08T16:31:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
I think you are affected by problem described here: https://github.com/kubernetes/minikube/issues/2733 I reproduced that case on my minikube on Ubuntu 18.04 and I can confirm the same error so it looks more like problem/bug in minikube.

No services for minikube windows "No connection could be made because the target machine actively refused it."

I have installed minikube via chocolatey on my windows 10 machine
I am using virtualbox for the VM
I have done minikube start and it is successful
Sporadically minikube status says that everything is running.
Usually, after I have started, the cluster is stopped.
I have disconnected from the VPN, restarted the computer, disconnected and reconnected to the internet, upgraded dropbox.
minikube service list returns either:
Get https://10.100.99.100:8443/api/v1/services: dial tcp 10.100.99.100:8443: connectex: No connection could be made because the target machine actively refused it.
Check that minikube is running and that you have specified the correct namespace (-n flag) if required.
Or
|-----------|------------|--------------|
| NAMESPACE | NAME | URL |
|-----------|------------|--------------|
| default | kubernetes | No node port |
|-----------|------------|--------------|
I have started with multiple different commands:
minikube start --vm-driver "virtualbox" --memory 8192 --disk-size 40g --host-only-cidr "10.100.99.1/24" being the most recent.
I have deleted and removed all machine files and then used the start command again to recreate the machine.
I have updated my config.json file to ensure that all slashes are "windows" slashes
I am completely at a loss for how to get this thing running.
I got this error after my setup was running fine and I had to restart my Windows 7 machine.
Is your docker VM running as expected?
If not, $docker-machine stop default
Followed by $docker-machine start default
minikube start --docker-env HTTP_PROXY=http://$YOURPROXY:PORT \ --docker-env HTTPS_PROXY=https://$YOURPROXY:PORT
Figure out if you are being blocked by a corporate proxy: https://superuser.com/questions/346372/how-do-i-know-what-proxy-server-im-using
The method using Chrome is the easiest

Error setting up docker on Windows

I am trying to set up docker machine on Windows and this problem has annoyed me for a few days.
I downloaded and installed DockerToolbox-1.9.1a on my Windows, so it came with Virtual Box version 5.0.10. After that I ran this command to create my virtual machine:
docker-machine create --driver virtualbox --engine-insecure-registry docker.pre-prod.ss.local:5000 --virtualbox-hostonly-cidr 192.168.99.100/24 mymachine
Here is what I got:
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available... Detecting
operating system of created instance... Detecting the provisioner...
Provisioning created instance... Copying certs to the local machine
directory... Copying certs to the remote machine... Setting Docker
configuration on the remote daemon... WARNING >>> This machine has
been allocated an IP address, but Docker Machine could not reach it
successfully.
SSH for the machine should still work, but connecting to exposed
ports, such as the Docker daemon port (usually :2376), may not
work properly.
You may need to add the route manually, or use another related
workaround
This could be due to a VPN, proxy, or host file configuration issue.
You also might want to clear any VirtualBox host only interfaces you
are not using
The machine was created successfully. So I ran the docker-machine env command:
docker-machine env --shell=powershell mymachine| Invoke-Expression
and I got:
Error running connection boilerplate: Error checking and/or
regenerating the certs: There was icates for host
"192.168.99.100:2376": dial tcp 192.168.99.100:2376: connectex: No
connection target machine actively refused it. You can attempt to
regenerate them using 'docker-machine regenerate-certs name'. Be
advised that this will trigger a Docker daemon restart which will stop
running containers.
Running docker version returned
Client: Version: 1.9.1 API version: 1.21 Go version:
go1.4.3 Git commit: a34a1d5 Built: Fri Nov 20 17:56:04 UTC
2015 OS/Arch: windows/amd64 An error occurred trying to connect:
Get http://localhost:2375/v1.21/version: dial tcp connection could be
made because the target machine actively refused it.
Can someone help to point out the direction to fix this issue? It is really troublesome to set up docker on Windows. Thank you very much.
I use docker 1.9.1 on Windows (7, 8 and even 10), but without docker registry, and without using --virtualbox-hostonly-cidr.
If you are to use that last option, check "Set a specific address ip when i create a docker container", where I mention issue 1709, which uses cidr in .1, not .100 (but getting a .100 ip address as a result):
docker-machine create -d virtualbox --virtualbox-hostonly-cidr "192.168.99.1/24" m99
If there's no other machine with the same cidr (Classless Inter-Domain Routing), the machine should always get the .100 IP upon start.

boot2docker - An error occurred trying to connect when running docker version command

When I use boot2docker to start the boot2docker-vm, then in gitbash I run the docker version command I get the following:
$ docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2
OS/Arch (client): windows/amd64
FATA[0021] An error occurred trying to connect: Get https://192.168.59.103:2376/v1.18/version: dial tcp 192.168.59.103:2376: ConnectEx tcp: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
However when I go into virtual box I see the boot2docker-vm is running.
When I stop the boot2docker-vm, & then start it myself - I can use the vm to use docker - it would be much easier to use gitbash to work with it...anyone have any ideas?
You have to init shell inside gitbash, use:
$ $(boot2docker shellinit)
in terminal.
Here is documentation for mac: https://docs.docker.com/installation/mac/.
This blog post describes the configuration of VirtualBox for Win64 systems after the boot2docker installation.
Change VirtualBox Global Settings to provide DHCP server on network adapter #2 instead of #3 with exactly the same settings as of #3
Change boot2docker-vm network configuration of the host-only network adapter from preconfigured adapter #3 to #2

Resources