Kubectl cannot connect to server: x509: certificate signed by an unknown authority

I get an error when starting kubectl one one machine (windows)

k8s cluster runs on CentOs 7 kubernetes cluster 1.7 master, worker

Here is my .kube \ config

  
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://10.10.12.7:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: system:node:localhost.localdomain
  name: system:node:localhost.localdomain@kubernetes
current-context: system:node:localhost.localdomain@kubernetes
kind: Config
preferences: {}
users:
- name: system:node:localhost.localdomain
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
  

cluster built using kubeadm with default certificates in pki directory

kubectl cannot connect to server: x509: certificate signed by an unknown user

+11
source share
7 answers

I just want to share, sorry I couldn’t provide this before, because I just realized that it causes

so on the main node we run the kubectl proxy

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

I stopped it and voila, the error disappeared.

    kubectl get nodes
NAME                    STATUS    AGE       VERSION
centos-k8s2             Ready     3d        v1.7.5
localhost.localdomain   Ready     3d        v1.7.5

, ,

+2

, kubelet kube

cat/etc/kubernetes/kubelet.conf> ~/.kube/config

+3

, - :

:

  • Windows 10
  • Kubernetes Docker Desktop ui 2.1.0.1
  • ~/.kube/config
  • ~/.kube/config server https://kubernetes.docker.internal:6443

: kubectl , kubectl --insecure-skip-tls-verify cluster-info dump, html.

: , URL , bash export no_proxy=$no_proxy,*.docker.internal

+3

:

gcloud container clusters get-credentials standard-cluster-1 --zone us-central1-a --project devops1-218400

devops1-218400 - . .

+1

kubecfg, . kops export kubecfg "your cluster-name export KOPS_STATE_STORE=s3://"paste your S3 store".

.

0

GCP

: gcloud

- localMacOS # gcloud

Run: --- localMacOS # gcloud container clusters get-credentials 'clusterName' \ - zone = us- 'zoneName'

Get clusterName and zoneName from the console - here: https://console.cloud.google.com/kubernetes/list ?

ref: .x509 @ placing on the market in GCP #Kubernetes

0
source

I got the same error when starting $ kubectl get nodesas root. I fixed this by exporting kubelet.confto an environment variable.

$ export KUBECONFIG=/etc/kubernetes/kubelet.conf
$ kubectl get nodes
0
source

Source: https://habr.com/ru/post/1685727/


All Articles