2017-08-02 34 views
0

在Windows上使用Kubectl客戶端(1.7.0)連接到遠程羣集。在kubeconfig中傳遞證書/密鑰會引發JSON錯誤

Windows中的配置文件(位於.kube)目錄的配置如下:

apiVersion: v1 
clusters: 
- cluster: 
    certificate-authority-data: C:\Users\DK05478\.kube\ca.crt 
    server: https://10.99.70.153:6443 
    name: devo 
contexts: 
- context: 
    cluster: devo 
    user: admindevo 
    name: devo 
current-context: devo 
kind: Config 
preferences: {} 
users: 
- name: admindevo 
    user: 
    client-certificate-data: C:\Users\DK05478\.kube\apiserver.crt 
    client-key-data: C:\Users\DK05478\.kube\apiserver.key 

我已經從遠程系統下載到我的本地這些證書文件。但這不起作用。引發以下錯誤 - >

C:\Windows\kubernetes>kubectl version 
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.0", GitCommit:"d3ada0119e776222f11ec7945e6d860061339aad", GitTreeState:"clean", BuildDate:"2017-06-29T23:15:59Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"windows/amd64"} 
error: Error loading config file "C:\Users\DK05478/.kube/config": [pos 107]: json: error decoding base64 binary 'C:\Users\DK05478\.kube\ca.crt': illegal base64 data at input byte 1 

如何解決此問題?我做錯了什麼?

回答

1

certificate-authority-dataclient-certificate-dataclient-key-data取出-data後綴。就像@sfgroups說的那樣,xxx-data參數是用於base64編碼的證書/密鑰。

一旦你這樣做,你的kubeconfig應該是這樣的:

apiVersion: v1 
clusters: 
- cluster: 
    certificate-authority: C:\Users\DK05478\.kube\ca.crt 
    server: https://10.99.70.153:6443 
    name: devo 
contexts: 
- context: 
    cluster: devo 
    user: admindevo 
    name: devo 
current-context: devo 
kind: Config 
preferences: {} 
users: 
- name: admindevo 
    user: 
    client-certificate: C:\Users\DK05478\.kube\apiserver.crt 
    client-key: C:\Users\DK05478\.kube\apiserver.key