How to make Kubernetes' RESTful api available from remote machines?

11/8/2016

I have set up a kubernetes cluster running on AWS. What I want to do now is to control the cluster from remote machines, for example, my macbook pro.

I've learned that Kubernetes has RESTful apis, and Kubectl can serve as a proxy. By running : kubectl proxy --port=8001 & I can access the RESTful api with curl, for example:

curl http://localhost:8001/api

Then I found that I can only curl the localhost. If I curl from a remote machine with the following command:

curl http://dns-to-the-k8-machine:8080/api

I will get a "Connection refused." I wonder what is happening here? And is there a way to easily access the apis remotely?

Thanks in advance.

-- Mohan Yang
kubectl
kubernetes

1 Answer

11/8/2016

Depending on how you provisioned your cluster, the API server may be listening over a different port. Have a look at your kubeconfig file (~/.kube/config), in there should be a section which has the server you are connecting to.

Also, your cluster may be using certs or some other type of authentication which you'll need to pass as well. Those will be outlined in the same kubeconfig file.

When using kubectl proxy, kubectl is handling the pieces mentioned above automatically, and proxying back to your laptop over localhost.

-- Steve Sloka
Source: StackOverflow