Unable to read client-cert and client-key when trying to run kubectl get pods with minikube

Viewed 3735

I'm on Ubuntu linux VM and trying to run minikube on it.

I installed kubectl via homebrew and then installed minikube by following below installation guides:
kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-linux
minikube: https://kubernetes.io/docs/tasks/tools/install-minikube/

I started minikube as sudo minikube start --driver=none which has the following output:
enter image description here

When I run the command: kubectl get pods, I get an error:

Error in configuration:
* unable to read client-cert /home/jenkins/.minikube/profiles/minikube/client.crt for minikube due to open /home/jenkins/.minikube/profiles/minikube/client.crt: permission denied
* unable to read client-key /home/jenkins/.minikube/profiles/minikube/client.key for minikube due to open /home/jenkins/.minikube/profiles/minikube/client.key: permission denied

The user I'm installing all above is /home/jenkins. I'm not sure what's going wrong. Can someone help?

3 Answers

There are 2 typical scenarios for such situations: either your keys were not created during minikube installation either you dont have proper permissions from your user.

For 1st case(not your) - you will clearly see in logs no such file or directory. To know more and how to resolve it - please refer to Unable to read client-cert/key Post Minikube Update

2nd is yours: client.crt: permission denied. Your current user doesnt have proper rights to read the file.

Resolution inside your screenshot. You should run below commands after cluster was created.

enter image description here

From #8363 shared by this answer, I did nano ~/.kube/config and corrected the path..

apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/username/.minikube/ca.crt
    server: https://192.168.64.3:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
users:
- name: minikube
  user:
    client-certificate: /home/username/.minikube/profiles/client.crt
    client-key: /home/username/.minikube/profiles/client.key
Related