昨天收到報警短信:集羣中某node狀態爲notReady,因爲是長期不用的,因此放到今天才有空處理,如下記錄處理過程。node
查看kubelet日誌,發現不停的打印證書過時相關提示信息。linux
如下操做基於kubernetes集羣版本:v1.6.6bootstrap
kubelete 證書默認有效期一年api
1.查看證書有效期,這裏使用之前下載的cfssl-certinfoapp
curl -s -L -o /usr/local/bin/cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
chmod +x /usr/local/bin/cfssl-certinfo
cfssl-certinfo -cert /etc/kubernetes/ssl/kubelet.crt
顯示內容以下:curl
{
"subject": {
"common_name": "test@1505813004",
"names": [
"test@1505813004"
]
},
"issuer": {
"common_name": "test@1505813004",
"names": [
"test@1505813004"
]
},
"serial_number": "1",
"sans": [
"test"
],
"not_before": "2017-10-24T09:23:24Z",
"not_after": "2018-10-24T09:23:24Z",
"sigalg": "SHA256WithRSA",
"authority_key_id": "",
"subject_key_id": "",
"pem": "-----BEGIN CERTIFICATE-----\nMIIDDKDK........EHi\nThGfI/wURC0=\n-----END CERTIFICATE-----\n"
}url
在證書過時node刪除kubelet相關證書文件及配置文件而後重啓kubelet,
kubelet會向apiserver發起一個csr
rm /etc/kubernetes/kubelet.kubeconfig
rm /etc/kubernetes/ssl/kubelet.*
systemctl restart kubelet
systemctl status kubeletrest
//查看未受權的CSR請求:
kubectl get csr
//approve CSR 請求:
kubectl certificate approve csr-4pw6g
NAME AGE REQUESTOR CONDITION
csr-4pw6g 1h kubelet-bootstrap Approved,Issued日誌
//重啓kubelet
systemctl restart kubeletserver
//查看node狀態
kubectl get no
NAME STATUS AGE VERSION
external Ready 1y v1.6.6