k8s執行kubectl相關命令報錯:Unable to connect to the server: x509


一、執行kubectl報錯

-rw------- 1 root root 5432 1月   4 11:29 scheduler.conf
[root@localhost kubernetes]# kubectl get nodes
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
[root@localhost kubernetes]# kubectl get svc
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

二、重新執行以下命令

[root@localhost kubernetes]# mkdir -p $HOME/.kube
[root@localhost kubernetes]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
cp:是否覆蓋"/root/.kube/config"? y
[root@localhost kubernetes]# chown $(id -u):$(id -g) $HOME/.kube/config

三、測試解決問題

[root@localhost kubernetes]# kubectl get nodes
NAME             STATUS   ROLES    AGE     VERSION
localhost        Ready    master   9h      v1.18.5
redis-01.hlqxt   Ready    <none>   4h51m   v1.18.5
redis-02.hlqxt   Ready    <none>   4h4m    v1.18.5
redis-03.hlqxt   Ready    <none>   4h4m    v1.18.5

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM