k3s执行helm命令报错:Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused

报错信息:

Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version?timeout=32s": dial tcp [::1]:8080: connect: connection refused

报错原因: helm v3版本不再需要Tiller,而是直接访问ApiServer来与k8s交互,通过环境变量KUBECONFIG来读取存有ApiServre的地址与token的配置文件地址,默认地址为~/.kube/config

解决方法:

手动配置 KUBECONFIG环境变量

  1. 临时解决: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

  2. 永久解决:

    • 执行: vi /etc/profile
    • 写入内容: export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
    • 执行: source /etc/profile
posted @ 2021-01-02 18:44  varyuan  阅读(4821)  评论(0编辑  收藏  举报