'Minikube : remote error tls: bad certificate

I'm following a Kubernetes tutorial, and cannot run first command (minikube start --vm-driver=hyperkit). I'm using a MacBook Pro Intel on macOs Monterey. I cannot make it work because of TLS error.

$ minikube start --vm-driver=hyperkit
😄  minikube v1.25.2 on Darwin 12.2.1
🆕  Kubernetes 1.23.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.23.3
✨  Using the hyperkit driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing hyperkit VM for "minikube" ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
❌  Problems detected in etcd [592b8a58065e]:
    2022-03-19 22:12:03.193985 I | embed: rejected connection from "127.0.0.1:38132" (error "remote error: tls: bad certificate", ServerName "")

I tried :

  1. Restarted the computer : https://github.com/kubernetes/minikube/issues/4329
  2. Used --embed-certs argument
$ minikube start --vm-driver=hyperkit --embed-certs
😄  minikube v1.25.2 on Darwin 12.2.1
🆕  Kubernetes 1.23.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.23.3
✨  Using the hyperkit driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing hyperkit VM for "minikube" ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
❌  Problems detected in etcd [78d1e36569b8]:
    2022-03-19 22:20:53.503532 I | embed: rejected connection from "127.0.0.1:34926" (error "remote error: tls: bad certificate", ServerName "")

I'm new to K8s, what could cause such behaviour ?


I installed minikube and hyperkit with homebrew. When I display the kubectl version I get another connection error :

kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.5", GitCommit:"5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e", GitTreeState:"clean", BuildDate:"2021-12-16T08:38:33Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"darwin/amd64"}
Unable to connect to the server: dial tcp 192.168.64.2:8443: i/o timeout


Solution 1:[1]

The kubectl version error helped : Unable to connect to the server: dial tcp i/o time out

It seems I had already played with k8s :

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Users/xxx/.minikube/ca.crt
    extensions:
    - extension:
        last-update: Sat, 13 Mar 2021 13:40:06 CET
        provider: minikube.sigs.k8s.io
        version: v1.18.1
      name: cluster_info
    server: https://192.168.64.2:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Sat, 13 Mar 2021 13:40:06 CET
        provider: minikube.sigs.k8s.io
        version: v1.18.1
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /Users/xxx/.minikube/profiles/minikube/client.crt
    client-key: /Users/xxx/.minikube/profiles/minikube/client.key

First I deleted the existing cluster :

$ kubectl config delete-cluster minikube
deleted cluster minikube from /Users/xxx/.kube/config

Then run

$ minikube delete
?  Deleting "minikube" in hyperkit ...
?  Removed all traces of the "minikube" cluster.

Finally :

$ minikube start --vm-driver=hyperkit
?  minikube v1.25.2 on Darwin 12.2.1
?  Using the hyperkit driver based on user configuration
?  Starting control plane node minikube in cluster minikube
?  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB  100.00% 923.34 K
?  Creating hyperkit VM (CPUs=2, Memory=4000MB, Disk=20000MB) ...
?  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    ? kubelet.housekeeping-interval=5m
    ? Generating certificates and keys ...
    ? Booting up control plane ...
    ? Configuring RBAC rules ...
?  Verifying Kubernetes components...
    ? Using image gcr.io/k8s-minikube/storage-provisioner:v5
?  Enabled addons: default-storageclass, storage-provisioner
?  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jean