1

docker desktop on mac is getting error:

Unable to connect to the server: x509: certificate signed by unknown authority

The following answers didn't helped much:

My system details:

  • Operating system: macOS Big Sur Version 11.6

  • Docker desktop version: v20.10.12

  • Kubernetes version: v1.22.5

When I do:

kubectl get pods

I get the below error:

Unable to connect to the server: x509: certificate signed by unknown authority
Wytrzymały Wiktor
  • 8,762
  • 5
  • 22
  • 32
Amit Meena
  • 1,470
  • 15
  • 22
  • 1
    check which context you are using for connecting with the k8s cluster and check your certificate details in `.kube/config` file details – Harsh Manvar Mar 07 '22 at 05:59
  • it is using correct context i.e docker-desktop – Amit Meena Mar 07 '22 at 08:59
  • There are a lot of possible reasons why it happens. Have you tried to reset the kubernetes cluster in docker desktop? Do you use the latest available version of docker desktop? I have macOS 12.0.1 and docker desktop 4.5.0. It always starts without any issues. – moonkotte Mar 07 '22 at 12:55
  • before docker desktop i have tried rancher desktop and i can see context and cluster meta for that also, performing a clean up using command kubectl config delete-context and kubectl config delete-cluster commands – Amit Meena Mar 07 '22 at 15:46
  • 1
    @AmitMeena Oh, that may be the answer. Untick "enable kubernetes", then delete `~/.kube` where config is stored and then re-enable the kubernetes. Most likely config is still presented from previous rancher installation. – moonkotte Mar 08 '22 at 09:41
  • 1
    @moonkotte exactly that is what I did and resolved the issue. Can you make an answer and I can accept it – Amit Meena Mar 08 '22 at 14:00

1 Answers1

1

Posting the answer from comments


As appeared after additional questions and answers, there was a previous installation of rancher cluster which left its traces: certificate and context in ~/.kube/config.

The solution in this case for local development/testing is to delete entirely ~/.kube folder with configs and init the cluster from the scratch.

moonkotte
  • 2,835
  • 2
  • 6
  • 22