|
| 1 | +--- |
| 2 | +title: 升级 Linux 节点 |
| 3 | +content_type: task |
| 4 | +weight: 100 |
| 5 | +--- |
| 6 | +<!-- |
| 7 | +title: Upgrading Linux nodes |
| 8 | +content_type: task |
| 9 | +weight: 100 |
| 10 | +--> |
| 11 | + |
| 12 | +<!-- overview --> |
| 13 | + |
| 14 | +<!-- |
| 15 | +This page explains how to upgrade a Linux Worker Nodes created with kubeadm. |
| 16 | +--> |
| 17 | +本页讲述了如何升级用 kubeadm 创建的 Linux 工作节点。 |
| 18 | + |
| 19 | +## {{% heading "prerequisites" %}} |
| 20 | + |
| 21 | +{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} |
| 22 | + |
| 23 | +<!-- |
| 24 | +* Familiarize yourself with [the process for upgrading the rest of your kubeadm |
| 25 | +cluster](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade). You will want to |
| 26 | +upgrade the control plane nodes before upgrading your Linux Worker nodes. |
| 27 | +--> |
| 28 | +* 你自己要熟悉[升级剩余 kubeadm 集群的过程](/zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade)。 |
| 29 | + 你需要先升级控制面节点,再升级 Linux 工作节点。 |
| 30 | + |
| 31 | +<!-- steps --> |
| 32 | + |
| 33 | +<!-- |
| 34 | +## Upgrading worker nodes |
| 35 | +
|
| 36 | +### Upgrade kubeadm |
| 37 | +
|
| 38 | +Upgrade kubeadm: |
| 39 | +--> |
| 40 | +## 升级工作节点 {#upgrading-worker-nodes} |
| 41 | + |
| 42 | +### 升级 kubeadm {#upgrade-kubeadm} |
| 43 | + |
| 44 | +升级 kubeadm: |
| 45 | + |
| 46 | +<!-- |
| 47 | +# replace x in {{< skew currentVersion >}}.x-00 with the latest patch version |
| 48 | +# replace x in {{< skew currentVersion >}}.x-0 with the latest patch version |
| 49 | +--> |
| 50 | +{{< tabs name="k8s_install_kubeadm_worker_nodes" >}} |
| 51 | +{{% tab name="Ubuntu、Debian 或 HypriotOS" %}} |
| 52 | +```shell |
| 53 | +# 将 {{< skew currentVersion >}}.x-00 中的 x 替换为最新的补丁版本 |
| 54 | +apt-mark unhold kubeadm && \ |
| 55 | +apt-get update && apt-get install -y kubeadm={{< skew currentVersion >}}.x-00 && \ |
| 56 | +apt-mark hold kubeadm |
| 57 | +``` |
| 58 | +{{% /tab %}} |
| 59 | +{{% tab name="CentOS、RHEL 或 Fedora" %}} |
| 60 | +```shell |
| 61 | +# 将 {{< skew currentVersion >}}.x-0 中的 x 替换为最新的补丁版本 |
| 62 | +yum install -y kubeadm-{{< skew currentVersion >}}.x-0 --disableexcludes=kubernetes |
| 63 | +``` |
| 64 | +{{% /tab %}} |
| 65 | +{{< /tabs >}} |
| 66 | + |
| 67 | +<!-- |
| 68 | +### Call "kubeadm upgrade" |
| 69 | +
|
| 70 | +- For worker nodes this upgrades the local kubelet configuration: |
| 71 | +--> |
| 72 | +### 执行 "kubeadm upgrade" {#call-kubeadm-upgrade} |
| 73 | + |
| 74 | +- 对于工作节点,下面的命令会升级本地的 kubelet 配置: |
| 75 | + |
| 76 | + ```shell |
| 77 | + sudo kubeadm upgrade node |
| 78 | + ``` |
| 79 | + |
| 80 | +<!-- |
| 81 | +### Drain the node |
| 82 | +
|
| 83 | +- Prepare the node for maintenance by marking it unschedulable and evicting the workloads: |
| 84 | +--> |
| 85 | +### 腾空节点 {#drain-node} |
| 86 | + |
| 87 | +- 将节点标记为不可调度并驱逐所有负载,准备节点的维护: |
| 88 | + |
| 89 | + <!-- |
| 90 | + # replace <node-to-drain> with the name of your node you are draining |
| 91 | + --> |
| 92 | + ```shell |
| 93 | + # 将 <node-to-drain> 替换为你正腾空的节点的名称 |
| 94 | + kubectl drain <node-to-drain> --ignore-daemonsets |
| 95 | + ``` |
| 96 | + |
| 97 | +<!-- |
| 98 | +### Upgrade kubelet and kubectl |
| 99 | +
|
| 100 | +- Upgrade the kubelet and kubectl: |
| 101 | +--> |
| 102 | +### 升级 kubelet 和 kubectl {#upgrade-kubelet-and-kubectl} |
| 103 | + |
| 104 | +- 升级 kubelet 和 kubectl: |
| 105 | + |
| 106 | + <!-- |
| 107 | + # replace x in {{< skew currentVersion >}}.x-00 with the latest patch version |
| 108 | + # replace x in {{< skew currentVersion >}}.x-0 with the latest patch version |
| 109 | + --> |
| 110 | + {{< tabs name="k8s_kubelet_and_kubectl" >}} |
| 111 | + {{% tab name="Ubuntu、Debian 或 HypriotOS" %}} |
| 112 | + ```shell |
| 113 | + # 将 {{< skew currentVersion >}}.x-00 中的 x 替换为最新的补丁版本 |
| 114 | + apt-mark unhold kubelet kubectl && \ |
| 115 | + apt-get update && apt-get install -y kubelet={{< skew currentVersion >}}.x-00 kubectl={{< skew currentVersion >}}.x-00 && \ |
| 116 | + apt-mark hold kubelet kubectl |
| 117 | + ``` |
| 118 | + {{% /tab %}} |
| 119 | + {{% tab name="CentOS、RHEL 或 Fedora" %}} |
| 120 | + ```shell |
| 121 | + # 将 {{< skew currentVersion >}}.x-0 中的 x 替换为最新的补丁版本 |
| 122 | + yum install -y kubelet-{{< skew currentVersion >}}.x-0 kubectl-{{< skew currentVersion >}}.x-0 --disableexcludes=kubernetes |
| 123 | + ``` |
| 124 | + {{% /tab %}} |
| 125 | + {{< /tabs >}} |
| 126 | + <br /> |
| 127 | + |
| 128 | +<!-- |
| 129 | +- Restart the kubelet: |
| 130 | +--> |
| 131 | +- 重启 kubelet: |
| 132 | + |
| 133 | + ```shell |
| 134 | + sudo systemctl daemon-reload |
| 135 | + sudo systemctl restart kubelet |
| 136 | + ``` |
| 137 | + |
| 138 | +<!-- |
| 139 | +### Uncordon the node |
| 140 | +
|
| 141 | +- Bring the node back online by marking it schedulable: |
| 142 | +--> |
| 143 | +### 取消对节点的保护 {#uncordon-node} |
| 144 | + |
| 145 | +- 通过将节点标记为可调度,让节点重新上线: |
| 146 | + |
| 147 | + <!-- |
| 148 | + # replace <node-to-uncordon> with the name of your node |
| 149 | + --> |
| 150 | + ```shell |
| 151 | + # 将 <node-to-uncordon> 替换为你的节点名称 |
| 152 | + kubectl uncordon <node-to-uncordon> |
| 153 | + ``` |
| 154 | + |
| 155 | +## {{% heading "whatsnext" %}} |
| 156 | + |
| 157 | +<!-- |
| 158 | +* See how to [Upgrade Windows nodes](/docs/tasks/administer-cluster/kubeadm/upgrading-windows-nodes/). |
| 159 | +--> |
| 160 | +* 查阅如何[升级 Windows 节点](/zh-cn/docs/tasks/administer-cluster/kubeadm/upgrading-windows-nodes/)。 |
0 commit comments