我有一個 Kubernetes 集群,有 2 個主節點和 3 個工作節點,我還有一個單獨的哈代理伺服器與公有IP。
預設情況下,kubeadm 產生叢集所需的所有憑證並將憑證儲存在 /etc/kubernetes/pki 中
根據文檔,我們可以將一個或多個自訂憑證和相關金鑰放在 /etc/kubernetes/pki 中並執行kubeadm 初始化命令生成其餘的證書。https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/
由於我的叢集已經啟動,運行 init 命令將因預檢錯誤而失敗。
所以我按照以下步驟產生憑證和 Kubernetes 配置
cd /etc/kubernetes/pki/
sudo rm ca.key ca.crt
sudo openssl genrsa -out ca.key 2048
sudo openssl req -x509 -new -nodes -key ca.key -subj "/CN=My Local CA" -days 10000 -out ca.crt
sudo kubeadm init phase certs all --control-plane-endpoint "haproxy_IP:6443"
cd /etc/kubernetes/
sudo rm admin.conf controller-manager.conf kubelet.conf scheduler.conf
sudo kubeadm init phase kubeconfig all --control-plane-endpoint "haproxy_IP:6443"
sudo rm $HOME/.kube/config
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
現在我遇到以下錯誤
kubectl 取得節點
Error from server (InternalError): an error on the server ("") has prevented the request from succeeding
openssl s_client -connect haproxy_IP:6443
CONNECTED(00000005)
write:errno=0
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 315 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
kubectl 取得節點 --v=7
09:41:50.597844 31816 request.go:943] Got a Retry-After 1s response for attempt 8 to https://haproxy_IP:6443/api?timeout=32s
09:41:51.598061 31816 round_trippers.go:422] GET https://haproxy_IP:6443/api?timeout=32s
09:41:51.598112 31816 round_trippers.go:429] Request Headers:
09:41:51.598219 31816 round_trippers.go:433] Accept: application/json, */*
09:41:51.598504 31816 round_trippers.go:433] User-Agent: kubectl/v1.20.4 (linux/amd64) kubernetes/e87da0b
09:41:51.602249 31816 round_trippers.go:448] Response Status: in 3 milliseconds
09:41:51.602301 31816 request.go:943] Got a Retry-After 1s response for attempt 9 to https://haproxy_IP:6443/api?timeout=32s
09:41:52.602523 31816 round_trippers.go:422] GET https://haproxy_IP:6443/api?timeout=32s
09:41:52.602558 31816 round_trippers.go:429] Request Headers:
09:41:52.602572 31816 round_trippers.go:433] User-Agent: kubectl/v1.20.4 (linux/amd64) kubernetes/e87da0b
09:41:52.602585 31816 round_trippers.go:433] Accept: application/json, */*
09:41:52.605922 31816 round_trippers.go:448] Response Status: in 3 milliseconds
09:41:52.605980 31816 request.go:943] Got a Retry-After 1s response for attempt 10 to https://haproxy_IP:6443/api?timeout=32s
09:41:53.606187 31816 round_trippers.go:422] GET https://haproxy_IP:6443/api?timeout=32s
09:41:53.610028 31816 round_trippers.go:429] Request Headers:
09:41:53.610048 31816 round_trippers.go:433] Accept: application/json, */*
09:41:53.610059 31816 round_trippers.go:433] User-Agent: kubectl/v1.20.4 (linux/amd64) kubernetes/e87da0b
09:41:53.612676 31816 round_trippers.go:448] Response Status: in 2 milliseconds
09:41:53.612837 31816 cached_discovery.go:121] skipped caching discovery info due to an error on the server ("") has prevented the request from succeeding
09:41:53.613146 31816 helpers.go:216] server response object: [{
"metadata": {},
"status": "Failure",
"message": "an error on the server (\"\") has prevented the request from succeeding",
"reason": "InternalError",
"details": {
"causes": [
{
"reason": "UnexpectedServerResponse"
}
],
"retryAfterSeconds": 1
},
"code": 500
}]
F0413 09:41:53.613294 31816 helpers.go:115] Error from server (InternalError): an error on the server ("") has prevented the request from succeeding
如果我重置新的證書和配置文件以及我以前的證書和配置文件然後一切工作正常沒有任何問題。
所以我懷疑我的方法中遺漏了一些東西。
非常感謝與此問題相關的想法或類似經驗。