Amit Meena
Amit Meena

Reputation: 4454

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

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:

When I do:

kubectl get pods

I get the below error:

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

Upvotes: 2

Views: 17150

Answers (2)

z atef
z atef

Reputation: 7699

If you are using a corporate laptop, and everything you do goes through a proxy, you will get this message. Hence, when docker desktop tries to connect to the server defined in ~/.kube/config, it will try to go through the proxy and you will need the cert issued by the company. Long story short, you are getting blocked by the the company... To fix, you can add the no proxy props, adding what ever value server: internal.docker defined in~/.kube/config . Meaning, if I am connecting to docker cluster which runs locally in my laptop, do not direct my traffic through proxy.

When doing docker info, after setting no proxy, you should see something like this.

docker info | grep -i proxy

 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal,localhost,127.0.0.1,.local,.us.example.com,.examplecorp.com,.examplevcn.com,kubernetes.docker.internal
  hubproxy.docker.internal:5000

Upvotes: 3

moonkotte
moonkotte

Reputation: 4181

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.

Upvotes: 7

Related Questions