<p>I'm setting up a 2 node cluster in kubernetes. 1 master node and 1 slave node.
After setting up master node I did installation steps of docker, kubeadm,kubelet, kubectl on worker node and then ran the join command. On master node, I see 2 nodes in Ready state (master and worker) but when I try to run any kubectl command on worker node, I'm getting connection refused error as below. I do not see any admin.conf and nothing set in .kube/config . Are these files also needed to be on worker node? and if so how do I get it? How to resolve below error? Appreciate your help</p>
<p>root@kubework:/etc/kubernetes# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?</p>
<p>root@kubework:/etc/kubernetes# kubectl cluster-info</p>
<p>To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server localhost:8080 was refused - did you specify the right host or port?
root@kubework:/etc/kubernetes#</p>

Nitish Goel
<blockquote>
<p>root@kubework:/etc/kubernetes# kubectl get nodes The connection to the
server localhost:8080 was refused - did you specify the right host or
port?</p>
</blockquote>
<p>Kubcetl is by default configured and working on the master.   It requires a kube-apiserver pod and <code>~/.kube/config</code>.</p>
<p>For worker nodes, we don’t need to use kube-apiserver but what we want is using the master configuration to pass by it.
To achieve it we have to copy the <code>~/.kube/config</code> file from the master to the <code>~/.kube/config</code> on the worker. Value <code>~</code> with the user executing kubcetl on the worker and master (that may be different of course).<br />
Once that done you could use the <code>kubectl</code> command from the worker node exactly as you do that from the master node.</p>
