<p>Ubuntu 19.4</p>

<p>Just installed kubectl via snap: <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/tools/install-kubectl/</a></p>

<pre><code>lky@lky-Z170-D3H:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
</code></pre>

<p>Any ideas what could cause it?</p>

Łukasz
<p>After installing <code>kubectl</code>, you have to configure it to use your cluster.
Almost any cloud providers, or bootstrappers such as <code>kubeadm</code> has easiest way to do it.
For example, on GKE you run below command to copy your cluster k8s config file, to localhost:</p>

<pre><code>gcloud container clusters get-credentials ${CLUSTER}
</code></pre>

<p>For Kops:</p>

<pre><code>kops export kubecfg ${CLUSTER}
</code></pre>

<p>For <code>kubeadm</code> you have to copy config file from master to your host machine. After completing <code>kubeadm init</code> command:</p>

<pre><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</code></pre>

<p>Note: <code>/etc/kubernetes/admin.conf</code> is located in master kubeadm node where you run <code>kubeadm init</code>, and you must copy this file to your host machine to use this cluster with <code>kubectl</code>.</p>

<p>Other useful links can be helpful:</p>

<p><a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-for-the-first-time-with-kubectl" rel="nofollow noreferrer">Accessing first time with kubectl</a>
<a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/" rel="nofollow noreferrer">Configure Access to Multiple Clusters</a></p>

<p>Hope it helps!</p>
