簡介
本檔案介紹在Cisco 5G RCM(備援組態管理員)中續訂Kubernetes憑證的程式。
必備條件
如果它是RCM高可用性設定,則必須先在備用RCM上執行該過程,然後執行切換,並在新的備用RCM上運行該過程。如果沒有RCM高可用性可用,則在RCM重新啟動期間(這是證書續訂流程的一部分)無法使用UP冗餘。
檢查證書是否過期
要確保證書是否過期,請運行sudo kubeadm alpha certs check-expiration。
ubuntu@rcm:~$ sudo kubeadm alpha certs check-expiration
CERTIFICATE EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
admin.conf Oct 31, 2024 03:34 UTC <invalid> no
apiserver Oct 31, 2024 03:34 UTC <invalid> no
apiserver-etcd-client Oct 31, 2024 03:34 UTC <invalid> no
apiserver-kubelet-client Oct 31, 2024 03:34 UTC <invalid> no
controller-manager.conf Oct 31, 2024 03:34 UTC <invalid> no
etcd-healthcheck-client Oct 31, 2024 03:34 UTC <invalid> no
etcd-peer Oct 31, 2024 03:34 UTC <invalid> no
etcd-server Oct 31, 2024 03:34 UTC <invalid> no
front-proxy-client Oct 31, 2024 03:34 UTC <invalid> no
scheduler.conf Oct 31, 2024 03:34 UTC <invalid> no
續訂憑證
運行sudo kubeadm alpha certs renew all以續訂證書。
ubuntu@rcm:~$ sudo kubeadm alpha certs renew all
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healtcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed
如果憑證已續訂,請再次檢查
運行sudo kubeadm alpha certs check-expiration以檢查證書是否已續訂。
ubuntu@rcm:~$ sudo kubeadm alpha certs check-expiration
CERTIFICATE EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
admin.conf Nov 01, 2025 03:34 UTC 364d no
apiserver Nov 01, 2025 03:34 UTC 364d no
apiserver-etcd-client Nov 01, 2025 03:34 UTC 364d no
apiserver-kubelet-client Nov 01, 2025 03:34 UTC 364d no
controller-manager.conf Nov 01, 2025 03:34 UTC 364d no
etcd-healthcheck-client Nov 01, 2025 03:34 UTC 364d no
etcd-peer Nov 01, 2025 03:34 UTC 364d no
etcd-server Nov 01, 2025 03:34 UTC 364d no
front-proxy-client Nov 01, 2025 03:34 UTC 364d no
scheduler.conf Nov 01, 2025 03:34 UTC 364d no
修改kubelet.conf
在kubeadm版本1.17之前,需要手動修改kubelet.conf。將client-certificate-data和client-key-data替換為。
/etc/kubernetes/kubelet.conf
client-certificate:/var/lib/kubelet/pki/kubelet-client-current.pem
client-key: /var/lib/kubelet/pki/kubelet-client-current.pem
Copy admin.conf
將admin.conf複製到.kube/config中。
sudo cp /etc/kubernetes/admin.conf ~/.kube/config
重新啟動系統
sudo reboot
請確定kubectl命令是否有效
重新開機後,請確認kubectl指令是否正常運作。
ubuntu@rcm:~$ kubectl get node
NAME STATUS ROLES AGE VERSION
rcm Ready master,oam 16d v1.15.12