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".
Be sure to set KUBERNETES_PUBLIC_ADDRESS to the public IP of your controller. Set the credentials for kubectl. Set the context for the cluster. Use the new kubectl context to check which pods are currently running on the cluster.
For the locally installed kubectl instance to remote access your Kubernetes cluster's API server running at https://cluster-ip-address:8443 , you need to setup a public we URL for the API server, so that you could access and manage the cluster from anywhere in the internet.
When kubectl accesses the cluster it uses a stored root certificate and client certificates to access the server. (These are installed in the ~/. kube directory). Since cluster certificates are typically self-signed, it may take special configuration to get your http client to use root certificate.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With