Installing helm a k3s node: Kubernetes cluster unreachable

2 min read | by Jordi Prats

Some times for convenience we might want to install helm on one of the k3s nodes. If we do so we'll get the following error:

# helm list
Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp connect: connection refused

This error is telling us that helm is not able to reach the Kubernetes cluster, but since we would expect it to be using 6443 instead of 8080 it is also telling us that it's not using any kubeconfig: That's because the default kubeconfig on a k3s node (or master) it is located under the etc directory (that would be /etc/rancher/k3s/k3s.yaml) instead of on the user's home directory.

To fix this using we just need to set the KUBECONFIG variable with the correct path:

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

Once this variable is set we'll be able to reach the K3S cluster using helm:

# helm list
NAME                          NAMESPACE   REVISION  UPDATED                                 STATUS    CHART                               APP VERSION    
alb-controller                kube-system 1         2022-07-01 19:57:04.704395322 +0000 UTC deployed  aws-load-balancer-controller-1.4.1  v2.4.1         
aws-cloud-controller-manager  kube-system 1         2022-07-01 19:57:04.09958298 +0000 UTC  deployed  aws-cloud-controller-manager-0.0.6  v1.23.0-alpha.0
ebs-csi                       kube-system 1         2022-07-01 19:57:03.554955011 +0000 UTC deployed  aws-ebs-csi-driver-2.6.7            1.6.1          
metrics-server                kube-system 1         2022-07-01 19:57:04.139117621 +0000 UTC deployed  metrics-server-3.8.2                0.6.1          
termination-handler           kube-system 1         2022-07-01 19:57:03.164567295 +0000 UTC deployed  aws-node-termination-handler-0.18.3 1.16.3         

Posted on 07/07/2022