7

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 ?
zar3bski
  • 2,773
  • 7
  • 25
  • 58

3 Answers3

18

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

Tarun Khosla
  • 1,274
  • 7
  • 10
  • Thanks, I was trying the same command without the --raw option and it didn't work. The "raw" option includes the certificates in the config file as well. – rkachach Dec 03 '20 at 10:02
  • This also works with k3s, by using `kubectl config view --raw > ~/.kube/config` – Jeter-work Apr 08 '22 at 22:08
0

Please try exporting kubeconfig file using following command: export KUBECONFIG=/var/snap/microk8s/current/credentials/client.config

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 03 '22 at 12:26
0

If you happen to be using WSL with docker desktop with k8s running in docker desktop but helm running in WSL a very similar command as provided by Tarun will also work.

Assuming you are running the Windows version of kubectl

➜  which kubectl.exe 
➜    /mnt/c/Program Files/Docker/Docker/resources/bin/kubectl.exe
➜  which kubectl 
➜    kubectl: aliased to /mnt/c/Program\ Files/Docker/Docker/resources/bin/kubectl.exe


➜  kubectl config view --raw > $HOME/.kube/config
Damo
  • 5,698
  • 3
  • 37
  • 55