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

8/10/2020

I configured my config file and when I run :

kubectl get nodes

I have this error :

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

I tried all this command but it still change nothing :

kubectl config set-cluster ${KUBE_CONTEXT} --insecure-skip-tls-verify=true \
--server=${KUBE_CONTEXT} 
--insecure-skip-tls-verify=true 

kubectl proxy --address 0.0.0.0 --accept-hosts '.*'
-- martin
kubernetes

1 Answer

8/10/2020

The error indicates a possible certificate mismatch.

Verify that the $HOME/.kube/config file contains a valid certificate, and regenerate a certificate if necessary.

Unset the KUBECONFIG environment variable using:

unset KUBECONFIG

Or set it to the default KUBECONFIG location:

export KUBECONFIG=/etc/kubernetes/admin.conf

Another workaround is to overwrite the existing kubeconfig for the "admin" user

mv  $HOME/.kube $HOME/.kube.bak
mkdir $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Refer Link

-- DT.
Source: StackOverflow