kubernetes: Getting started: "Running Kubernetes Locally via Docker" doesn't work on Max OS X

Problem description

The “Download kubectl” section mentions the following:

Create configuration:

$ kubectl config set-cluster test-doc --server=http://localhost:8080
$ kubectl config set-context test-doc --cluster=test-doc
$ kubectl config use-context test-doc

For Max OS X users instead of localhost you will have to use IP address of your docker machine, which you can find by running docker-machine env <machinename> (see documentation for details).

The docker run command doesn’t publish any ports though, so the above does not work even if localhost is replaced with the correct IP address of the docker machine.

kubectl get nodes will then fail with:

The connection to the server 192.168.99.100:8080 was refused - did you specify the right host or port?

Note: 192.168.99.100 is the IP of the docker machine that I configured as described

Hypothesis

It looks like the API server (?) port 8080 needs to be published.

Workaround

A workaround is to keep using localhost in the configuration line above and to then set up an SSH tunnel:

docker-machine ssh $MACHINE_NAME -N -L 8080:localhost:8080

(where $MACHINE_NAME is the name of the docker machine being used, docker-machine ls can be used to list all running machines).

This is sufficient to make kubectl get nodes work as described.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 15
  • Comments: 25 (16 by maintainers)

Most upvoted comments

For google this is not acceptable especially when they preach on how to build systems that can take care of all the internal plumbing with single command.

@pwittrock This doesn’t work on Docker for Mac either. I keep setting the The connection to the server localhost:8080 was refused - did you specify the right host or port? message.

cc @dlorenc

@onlydole would you be willing to try https://github.com/kubernetes/minikube to see if it provides you what you need? It hasn’t been generally released yet, but it would be helpful to get your feedback.

@augieschwer Thanks for pointing that out. We need to update that page to correct the version as well as add the ssh tunnel command. We have discussed some solutions to make bootstrapping a local environment more user friendly and are hoping to improve this experience.

@vishh Since you are planning on working on / coordinating this update, would you make sure all of the version are correct. The docker image version should probably be changed to v1.2.0 as well.