我有一個在私有雲中運行的 Kubernetes 叢集。我想從另一個虛擬機器運行一些命令,但收到以下訊息:
[root@runner-tmp ~]# kubectl get pods --kubeconfig local-cluster.yaml
error: tls: failed to find any PEM data in certificate input
我的 local-cluster.yaml:
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://x.x.x.x:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
namespace: FSM
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
您知道我應該在哪裡指定此 PEM 憑證以及如何產生它嗎?
答案1
error: tls: failed to find any PEM data in certificate input
當您將輸出複製kubectl config view
到遠端虛擬機器時,會出現訊息。
因此,kubectl config view
您應該提供config
通常存在於$HOME/.kube/config
.
您可以透過執行scp root@<control-plane-host>:/etc/kubernetes/admin.conf .
然後提供此文件來完成此操作--kubeconfig
,例如:
kubectl --kubeconfig ./admin.conf get nodes