Azure DevOps進行Kubernetes CD部署時出現憑證錯誤

Azure DevOps進行Kubernetes CD部署時出現憑證錯誤

同事回報,進行 Kubernetes CD 部署時出現錯誤:

couldn't get current server API group list: the server has asked for the client to provide credentials
unable to recognize "...API.yaml": the server has asked for the client to provide credentials

連線進主機看不出問題,請另一同事確認,很快發現問題。

$ kubectl get pods -o wide
E0514 10:58:14.270861 3626694 memcache.go:265] couldn't get current server API group list: the server has asked for the client to provide credentials
error: You must be logged in to the server (the server has asked for the client to provide credentials)

立即了解到原因,最近進行了 Kubernetes 叢集核心升級,升級會造成新舊憑證共存的現象。我連進主機不會有問題是因為,我的帳號已更新了憑證,剛好同事的帳號是沒更新的舊憑證。

解決辦法也很簡單:

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

請有 Kubernetes 管理權限的同事們更新一下 .kube 的 config 組態檔,這樣就能拿到最新版憑證組態檔。也就是說,下次升級完 Kubernetes 叢集核心後,要請所有管理者(含部署帳號)更新 config 組態檔。

又學到了一課。

沒有留言:

張貼留言

感謝您的留言,如果我的文章你喜歡或對你有幫助,按個「讚」或「分享」它,我會很高興的。