1
votes

I installed Kubernetes on linux using the steps here.

Everything worked fine until I exited the terminal and opened a new terminal session.

I got a permission denied error and after restarting my machine I get the following error

> kubectl get pod<br/>
error: couldn't read version from server: Get http://localhost:8080/api: dial tcp 127.0.0.1:8080: connection refused

I am just getting started with Kubernetes any help would be appreciated.

2

2 Answers

1
votes

I tried replicating the problem by doing this:

  1. Installed Kubernetes on a fresh ubuntu 15.04 machine from the instructions given in your link above.
  2. stopped (with docker) all the containers as given in the instructions.
  3. logged out and logged in again
  4. Started etcd and then kubernetes master and then the service proxy to get them up again.

Then immediately I ran get nodes to get the same error as yours.

[anovil@ubuntu-anovil ~]$ kubectl get nodes
error: couldn't read version from server: Get http://localhost:8080/api: dial tcp 127.0.0.1:8080: connection refused

[anovil@ubuntu-anovil ~]$ 

Then I ran docker ps to check if they are all running and seems not the case.

[anovil@ubuntu-anovil ~]$ docker ps
CONTAINER ID        IMAGE                                       COMMAND                  CREATED              STATUS              PORTS               NAMES
449b4751f0e4        gcr.io/google_containers/pause:0.8.0        "/pause"                 3 seconds ago        Up 2 seconds                            k8s_POD.e4cc795_k8s-master-127.0.0.1_default_f3ccbffbd75e3c5d2fb4ba69c8856c4a_b169f4ad
8c37ad726b71        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube proxy --m"   55 seconds ago       Up 55 seconds                           naughty_jennings
de9cf798bc2b        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube kubelet -"   About a minute ago   Up About a minute                       desperate_pike
6d969a37428e        gcr.io/google_containers/etcd:2.0.12        "/usr/local/bin/etcd "   About a minute ago   Up About a minute                       jovial_jang
[anovil@ubuntu-anovil ~]$

As you see, the controllers, apiserver and scheduler were missing. If this would have been your problem, then I just waited for a while, say 1 minute and they were all up again.

So, it just took some time to resume, after which

[anovil@ubuntu-anovil ~]$ kubectl get nodes
NAME        LABELS                             STATUS
127.0.0.1   kubernetes.io/hostname=127.0.0.1   Ready
[anovil@ubuntu-anovil ~]$ docker ps
CONTAINER ID        IMAGE                                       COMMAND                  CREATED              STATUS              PORTS               NAMES
0b8b7aae8143        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube scheduler"   8 seconds ago        Up 8 seconds                            k8s_scheduler.2744e742_k8s-master-127.0.0.1_default_f3ccbffbd75e3c5d2fb4ba69c8856c4a_6928bc83
0e25d641079b        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube apiserver"   8 seconds ago        Up 8 seconds                            k8s_apiserver.cfb70250_k8s-master-127.0.0.1_default_f3ccbffbd75e3c5d2fb4ba69c8856c4a_1f35ee04
d5170a4bcd58        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube controlle"   8 seconds ago        Up 8 seconds                            k8s_controller-manager.1598ee5c_k8s-master-127.0.0.1_default_f3ccbffbd75e3c5d2fb4ba69c8856c4a_e9c8eaa4
449b4751f0e4        gcr.io/google_containers/pause:0.8.0        "/pause"                 18 seconds ago       Up 18 seconds                           k8s_POD.e4cc795_k8s-master-127.0.0.1_default_f3ccbffbd75e3c5d2fb4ba69c8856c4a_b169f4ad
8c37ad726b71        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube proxy --m"   About a minute ago   Up About a minute                       naughty_jennings
de9cf798bc2b        gcr.io/google_containers/hyperkube:v1.0.1   "/hyperkube kubelet -"   About a minute ago   Up About a minute                       desperate_pike
6d969a37428e        gcr.io/google_containers/etcd:2.0.12        "/usr/local/bin/etcd "   About a minute ago   Up About a minute                       jovial_jang
[anovil@ubuntu-anovil ~]$ 

The first thing you should do after starting the etcd, master and proxy is to check with docker ps and see if they all are up.

Also, if you still have problems then can you try posting your docker version, your host details (OS, version etc.)?

Thanks, (I do not have enough reputations to comment on this request)

3
votes

seems like a TCP problem. try to isolate the problem by checking if TCP/8080 is open by issue

telnet 127.0.0.1 8080

if you got a 'connection refused' - you should probably look at the firewall/security setting of your machine.