升級 Windows 節點
特性狀態:
Kubernetes v1.18 [beta]
本頁面解釋瞭如何升級使用 kubeadm 建立的 Windows 節點。
準備工作
你需要擁有所有節點的 shell 訪問許可權,並且 kubectl 命令列工具必須配置為與你的叢集通訊。建議在至少有兩個不作為控制平面主機的節點的叢集上執行本教程。
你的 Kubernetes 伺服器版本必須等於或晚於 1.17。要檢查版本,請輸入 kubectl version
。
- 熟悉 升級 kubeadm 叢集其餘部分的過程。你需要在升級 Windows 節點之前升級控制平面節點。
升級工作節點
升級 kubeadm
在 Windows 節點上,升級 kubeadm
# replace 1.34.0 with your desired version curl.exe -Lo <path-to-kubeadm.exe> "https://dl.k8s.io/v1.34.0/bin/windows/amd64/kubeadm.exe"
騰空節點
在可以訪問 Kubernetes API 的機器上,透過將節點標記為不可排程並驅逐工作負載來準備節點進行維護
# replace <node-to-drain> with the name of your node you are draining kubectl drain <node-to-drain> --ignore-daemonsets
你應該看到類似以下內容的輸出
node/ip-172-31-85-18 cordoned node/ip-172-31-85-18 drained
升級 kubelet 配置
在 Windows 節點上,呼叫以下命令同步新的 kubelet 配置
kubeadm upgrade node
升級 kubelet 和 kube-proxy
在 Windows 節點上,升級並重啟 kubelet
stop-service kubelet curl.exe -Lo <path-to-kubelet.exe> "https://dl.k8s.io/v1.34.0/bin/windows/amd64/kubelet.exe" restart-service kubelet
在 Windows 節點上,升級並重啟 kube-proxy。
stop-service kube-proxy curl.exe -Lo <path-to-kube-proxy.exe> "https://dl.k8s.io/v1.34.0/bin/windows/amd64/kube-proxy.exe" restart-service kube-proxy
注意
如果你在 Pod 中以 HostProcess 容器的形式執行 kube-proxy,而不是作為 Windows 服務執行,你可以透過應用更新版本的 kube-proxy 清單來升級 kube-proxy。取消封鎖節點
在可以訪問 Kubernetes API 的機器上,透過將節點標記為可排程來使節點恢復線上
# replace <node-to-drain> with the name of your node kubectl uncordon <node-to-drain>
下一步
- 請參閱如何 升級 Linux 節點。
上次修改時間為 2024 年 9 月 13 日下午 4:59 PST:重組 kubeadm 節點任務 (c8bb00db5d)