I followed the Kubernetes docs for setting up a single node cluster as a Docker container. I now have Kubernetes running on a remote Linux VM (say, mykube01.example.com
).
I then downloaded and installed kubectl
locally on my Mac laptop. I can run kubectl version
and it verifies I have installed the correct version.
I then went to configure kubectl
by following this doc and created the following ~/.kube/config
file:
apiVersion: v1
clusters:
- cluster:
api-version: v1
server: http://mykube01.example.com:8080
name: testkube
When I run kubectl cluster-info
I get:
Kubernetes master is running at http://mykuber01.example.com:8080
But when I run kubetctl get nodes
I get:
The connection to the server mykube01.example.com:8080 was refused - did you specify the right host or port?
Any ideas where I'm going awry? I want to get to the point where I can keep going with that first Kubernetes doc and deploy nginx to the 1-node cluster via:
kubectl -s http://mykube01.example.com:8080 run-container nginx --image=nginx --port=80
But I can't do that until I get kubectl
configured properly and correctly connecting to my remote "cluster".
When you created the connection to your master, a file should be created:
/etc/kubernetes/kubelet.conf
By default, your personal config is empty or missing. So, I copied the above mentioned kubelet.conf file as my ~/.kube/config
file. Worked perfectly.
(moving the "reply" down into the "answer" so that this appears as "answered"
kubectl just uses HTTP(S) by default. As the person said above, try using 'curl mykube01.example.com:8080/api/v1/nodes' or open that URL in a browser and see if that works.
If that works, but kubectl doesn't then there is a problem in kubectl or your config. If curl or the browser don't work, the problem is in the network somewhere.