Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm 3: x509 error when connecting to local Kubernetes

I'm a perfect noob with K8s. I installed microk8s and Helm using snap to experiment locally. I wonder whether my current issue comes from the use of snap (purpose of which is encapsulation, from what I understood)

Environment

Ubuntu 20.04LTS

helm version                                                                            
version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
kubectl version     
Client Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.4-1+6f17be3f1fd54a", GitCommit:"6f17be3f1fd54a88681869d1cf8bedd5a2174504", GitTreeState:"clean", BuildDate:"2020-06-23T21:16:24Z", GoVersion:"go1.14.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.4-1+6f17be3f1fd54a", GitCommit:"6f17be3f1fd54a88681869d1cf8bedd5a2174504", GitTreeState:"clean", BuildDate:"2020-06-23T21:17:52Z", GoVersion:"go1.14.4", Compiler:"gc", Platform:"linux/amd64"}
kubectl config get-contexts                                                             
CURRENT   NAME       CLUSTER            AUTHINFO   NAMESPACE
*         microk8s   microk8s-cluster   admin      

Post install set up

microk8s enable helm3

Kubernetes is up and running

kubectl cluster-info 
Kubernetes master is running at https://127.0.0.1:16443
CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

Problem while connecting helm to microk8s

helm ls --kube-token ~/token --kube-apiserver https://127.0.0.1:16443
Error: Kubernetes cluster unreachable: Get https://127.0.0.1:16443/version?timeout=32s: x509: certificate signed by unknown authority

How can I tell helm

  • to trust microk8s certs or
  • to ignore this verification step

From what I read, I may overcome this issue by pointing to kube's config using --kubeconfig.

helm ls --kube-token ~/token --kube-apiserver https://127.0.0.1:16443 --kubeconfig /path/to/kubernetes/config

In the context of microk8s installed with snap, I am not quite sure what this conf file is nor where to find it.

  • /snap/microk8s/1503 ?
  • /var/snap/microk8s/1503 ?
like image 453
zar3bski Avatar asked Jul 23 '20 09:07

zar3bski


1 Answers

Helm looks for kubeconfig at this path $HOME/.kube/config.

Please run this command

microk8s.kubectl config view --raw > $HOME/.kube/config

This will save the config at required path in your directory and shall work

Reference Link here

like image 196
Tarun Khosla Avatar answered Sep 19 '22 12:09

Tarun Khosla