Windows上的kubectl抛出错误您必须登录到服务器

时间:2018-03-23 01:47:40

标签: kubernetes kubectl minikube

我在我的Windows笔记本电脑上安装了minikube,一切都很好,但当我尝试运行kubectl get pod或任何其他kubectl命令时,我收到此消息:

kubectl get pod
error: You must be logged in to the server (Unauthorized)

即使我将凭据添加到配置中,我也不知道我做错了什么:

apiVersion: v1
clusters:
- cluster:
    certificate-authority: C:\Users\robert\.minikube\ca.crt
    server: https://192.168.99.100:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    as-user-extra: {}
    client-certificate: C:\Users\robert\.minikube\client.crt
    client-key: C:\Users\robert\.minikube\client.key

minikube info

minikube version
minikube version: v0.25.1

minikube升级

minikube version: v0.25.2

Kubernetes信息

kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.6", GitCommit:"9f8ebd171479bec0ada837d7ee641dec2f8c6dd1", GitTreeState:"clean", BuildDate:"2018-03-21T15:21:50Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"windows/amd64"}
error: You must be logged in to the server (the server has asked for the client to provide credentials)

minikube目录和文件

    Directory: C:\Users\robert\.minikube


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        3/22/2018   1:40 PM                addons
d-----        3/22/2018   1:40 PM                cache
d-----        3/22/2018   1:40 PM                certs
d-----        3/22/2018   1:47 PM                config
d-----        3/22/2018   1:40 PM                files
d-----        3/22/2018   1:40 PM                logs
d-----        3/22/2018   9:42 PM                machines
d-----        3/22/2018   2:32 PM                profiles
-a----        3/22/2018  10:56 PM           1298 apiserver.crt
-a----        3/22/2018  10:56 PM           1679 apiserver.key
-a----        3/22/2018   2:33 PM           1066 ca.crt
-a----        3/22/2018   2:33 PM           1675 ca.key
-ar---        3/22/2018  10:55 PM           1054 ca.pem
-ar---        3/22/2018  10:55 PM           1094 cert.pem
-a----        3/22/2018  10:56 PM           1103 client.crt
-a----        3/22/2018  10:56 PM           1675 client.key
-ar---        3/22/2018  10:55 PM           1679 key.pem
-a----        3/22/2018   7:29 PM             29 last_update_check
-a----        3/22/2018   2:33 PM           1074 proxy-client-ca.crt
-a----        3/22/2018   2:33 PM           1675 proxy-client-ca.key
-a----        3/22/2018  10:56 PM           1103 proxy-client.crt
-a----        3/22/2018  10:56 PM           1675 proxy-client.key

minikube logs

Mar 23 03:04:18 minikube localkube[2997]: I0323 03:04:18.212816    2997 ready.go:30] Performing healthcheck on https://localhost:8443/healthz
Mar 23 03:04:18 minikube localkube[2997]: E0323 03:04:18.219072    2997 ready.go:40] Error performing healthcheck: Get https://localhost:8443/healthz: x509: certificate has expired or is not yet valid
Mar 23 03:04:18 minikube localkube[2997]: http: TLS handshake error from 127.0.0.1:41884: remote error: tls: bad certificate
Mar 23 03:04:19 minikube localkube[2997]: I0323 03:04:19.212786    2997 ready.go:30] Performing healthcheck on https://localhost:8443/healthz
Mar 23 03:04:19 minikube localkube[2997]: E0323 03:04:19.219637    2997 ready.go:40] Error performing healthcheck: Get https://localhost:8443/healthz: x509: certificate has expired or is not yet valid
Mar 23 03:04:19 minikube localkube[2997]: http: TLS handshake error from 127.0.0.1:41886: remote error: tls: bad certificate

证书详情

openssl x509 -in apiserver.crt -text -noout
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 2 (0x2)
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN=minikubeCA
        Validity
            Not Before: Mar 23 18:05:14 2018 GMT
            Not After : Mar 23 18:05:14 2019 GMT
        Subject: O=system:masters, CN=minikube
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:b5:fa:...fa:e7
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage:
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Alternative Name:
                DNS:minikubeCA, DNS:kubernetes.default.svc.cluster.local, DNS:kubernetes.default.svc, DNS:kubernetes.default, DNS:kubernetes, DNS:localhost, IP Address:192.168.99.100, IP Address:10.96.0.1, IP Address:10.0.0.1
    Signature Algorithm: sha256WithRSAEncryption
         47:88:26:93:d2.....
         ab:b1:8a:43

1 个答案:

答案 0 :(得分:1)

首先,根据报告的thishere,检查问题是否仍然存在于最新版本(0.25.2,几个小时前发布)< / p>

其次,检查证书的形成方式(here

openssl x509 -in apiserver.crt -text -noout

和/或尝试in this issue