|
| 1 | +--- |
| 2 | +title: 升级集群 |
| 3 | +content_type: task |
| 4 | +--- |
| 5 | +<!-- |
| 6 | +--- |
| 7 | +title: Upgrade A Cluster |
| 8 | +content_type: task |
| 9 | +--- |
| 10 | +--> |
| 11 | + |
| 12 | +<!-- overview --> |
| 13 | +<!-- |
| 14 | +This page provides an overview of the steps you should follow to upgrade a |
| 15 | +Kubernetes cluster. |
| 16 | +
|
| 17 | +The way that you upgrade a cluster depends on how you initially deployed it |
| 18 | +and on any subsequent changes. |
| 19 | +
|
| 20 | +At a high level, the steps you perform are: |
| 21 | +--> |
| 22 | +本页概述升级 Kubernetes 集群的步骤。 |
| 23 | + |
| 24 | +升级集群的方式取决于你最初部署它的方式、以及后续更改它的方式。 |
| 25 | + |
| 26 | +从高层规划的角度看,要执行的步骤是: |
| 27 | + |
| 28 | +<!-- |
| 29 | +- Upgrade the {{< glossary_tooltip text="control plane" term_id="control-plane" >}} |
| 30 | +- Upgrade the nodes in your cluster |
| 31 | +- Upgrade clients such as {{< glossary_tooltip text="kubectl" term_id="kubectl" >}} |
| 32 | +- Adjust manifests and other resources based on the API changes that accompany the |
| 33 | + new Kubernetes version |
| 34 | +--> |
| 35 | +- 升级{{< glossary_tooltip text="控制平面" term_id="control-plane" >}} |
| 36 | +- 升级集群中的节点 |
| 37 | +- 升级 {{< glossary_tooltip text="kubectl" term_id="kubectl" >}} 之类的客户端 |
| 38 | +- 根据新 Kubernetes 版本带来的 API 变化,调整清单文件和其他资源 |
| 39 | + |
| 40 | +## {{% heading "prerequisites" %}} |
| 41 | + |
| 42 | +<!-- |
| 43 | +You must have an existing cluster. This page is about upgrading from Kubernetes |
| 44 | +{{< skew prevMinorVersion >}} to Kubernetes {{< skew latestVersion >}}. If your cluster |
| 45 | +is not currently running Kubernetes {{< skew prevMinorVersion >}} then please check |
| 46 | +the documentation for the version of Kubernetes that you plan to upgrade to. |
| 47 | +--> |
| 48 | +你必须有一个集群。 |
| 49 | +本页内容涉及从 Kubernetes {{< skew prevMinorVersion >}} |
| 50 | +升级到 Kubernetes {{< skew latestVersion >}}。 |
| 51 | +如果你的集群未运行 Kubernetes {{< skew prevMinorVersion >}}, |
| 52 | +那请参考目标 Kubernetes 版本的文档。 |
| 53 | + |
| 54 | +<!-- ## Upgrade approaches --> |
| 55 | +## 升级方法 {#upgrade-approaches} |
| 56 | + |
| 57 | +### kubeadm {#upgrade-kubeadm} |
| 58 | + |
| 59 | +<!-- |
| 60 | +If your cluster was deployed using the `kubeadm` tool, refer to |
| 61 | +[Upgrading kubeadm clusters](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/) |
| 62 | +for detailed information on how to upgrade the cluster. |
| 63 | +
|
| 64 | +Once you have upgraded the cluster, remember to |
| 65 | +[install the latest version of `kubectl`](/docs/tasks/tools/install-kubectl/). |
| 66 | +--> |
| 67 | +如果你的集群是使用 `kubeadm` 安装工具部署而来, |
| 68 | +那么升级群集的详细信息,请参阅 |
| 69 | +[升级 kubeadm 集群](/zh/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/)。 |
| 70 | + |
| 71 | +升级集群之后,要记得 |
| 72 | +[安装最新版本的 `kubectl`](/zh/docs/tasks/tools/install-kubectl/). |
| 73 | + |
| 74 | +<!-- ### Manual deployments --> |
| 75 | +### 手动部署 {#manual-deployments} |
| 76 | + |
| 77 | +<!-- |
| 78 | +These steps do not account for third-party extensions such as network and storage |
| 79 | +plugins. |
| 80 | +
|
| 81 | +You should manually update the control plane following this sequence: |
| 82 | +--> |
| 83 | +{{< caution >}} |
| 84 | +这些步骤不考虑第三方扩展,例如网络和存储插件。 |
| 85 | +{{< /caution >}} |
| 86 | + |
| 87 | +你应该跟随下面操作顺序,手动更新控制平面: |
| 88 | + |
| 89 | +<!-- |
| 90 | +- etcd (all instances) |
| 91 | +- kube-apiserver (all control plane hosts) |
| 92 | +- kube-controller-manager |
| 93 | +- kube-scheduler |
| 94 | +- cloud controller manager, if you use one |
| 95 | +--> |
| 96 | +- etcd (所有实例) |
| 97 | +- kube-apiserver (所有控制平面的宿主机) |
| 98 | +- kube-controller-manager |
| 99 | +- kube-scheduler |
| 100 | +- cloud controller manager, 在你用到时 |
| 101 | + |
| 102 | +<!-- |
| 103 | +At this point you should |
| 104 | +[install the latest version of `kubectl`](/docs/tasks/tools/install-kubectl/). |
| 105 | +
|
| 106 | +For each node in your cluster, [drain](/docs/tasks/administer-cluster/safely-drain-node/) |
| 107 | +that node and then either replace it with a new node that uses the {{< skew latestVersion >}} |
| 108 | +kubelet, or upgrade the {{< skew latestVersion >}} |
| 109 | +kubelet on that node and bring the node back into service. |
| 110 | +--> |
| 111 | +现在,你应该 |
| 112 | +[安装最新版本的 `kubectl`](/zh/docs/tasks/tools/install-kubectl/). |
| 113 | + |
| 114 | +对于群集中的每个节点, |
| 115 | +[排空](/zh/docs/tasks/administer-cluster/safely-drain-node/) |
| 116 | +节点,然后,或者用一个运行了 {{< skew latestVersion >}} kubelet 的新节点替换它; |
| 117 | +或者升级此节点的 kubelet,并使节点恢复服务。 |
| 118 | + |
| 119 | +<!-- |
| 120 | +### Other deployments {#upgrade-other} |
| 121 | +
|
| 122 | +Refer to the documentation for your cluster deployment tool to learn the recommended set |
| 123 | +up steps for maintenance. |
| 124 | +
|
| 125 | +## Post-upgrade tasks |
| 126 | +
|
| 127 | +### Switch your cluster's storage API version |
| 128 | +--> |
| 129 | +### 其他部署方式 {#upgrade-other} |
| 130 | + |
| 131 | +参阅你的集群部署工具对应的文档,了解用于维护的推荐设置步骤。 |
| 132 | + |
| 133 | +## 升级后的任务 {#post-upgrade-tasks} |
| 134 | + |
| 135 | +### 切换群集的存储 API 版本 {#switch-your-clusters-storage-api-version} |
| 136 | + |
| 137 | +<!-- |
| 138 | +The objects that are serialized into etcd for a cluster's internal |
| 139 | +representation of the Kubernetes resources active in the cluster are |
| 140 | +written using a particular version of the API. |
| 141 | +
|
| 142 | +When the supported API changes, these objects may need to be rewritten |
| 143 | +in the newer API. Failure to do this will eventually result in resources |
| 144 | +that are no longer decodable or usable by the Kubernetes API server. |
| 145 | +
|
| 146 | +For each affected object, fetch it using the latest supported API and then |
| 147 | +write it back also using the latest supported API. |
| 148 | +--> |
| 149 | +对象序列化到 etcd,是为了提供集群中活动 Kubernetes 资源的内部表示法, |
| 150 | +这些对象都使用特定版本的 API 编写。 |
| 151 | + |
| 152 | +当底层的 API 更改时,这些对象可能需要用新 API 重写。 |
| 153 | +如果不能做到这一点,会导致再也不能用 Kubernetes API 服务器解码、使用该对象。 |
| 154 | + |
| 155 | +对于每个受影响的对象,用最新支持的 API 获取它,然后再用最新支持的 API 写回来。 |
| 156 | + |
| 157 | +<!-- |
| 158 | +### Update manifests |
| 159 | +
|
| 160 | +Upgrading to a new Kubernetes version can provide new APIs. |
| 161 | +
|
| 162 | +You can use `kubectl convert` command to convert manifests between different API versions. |
| 163 | +For example: |
| 164 | +--> |
| 165 | +### 更新清单 {#update-manifests} |
| 166 | + |
| 167 | +升级到新版本 Kubernetes 就可以提供新的 API。 |
| 168 | + |
| 169 | +你可以使用 `kubectl convert` 命令在不同 API 版本之间转换清单。 |
| 170 | +例如: |
| 171 | + |
| 172 | +```shell |
| 173 | +kubectl convert -f pod.yaml --output-version v1 |
| 174 | +``` |
| 175 | + |
| 176 | +<!-- |
| 177 | +The `kubectl` tool replaces the contents of `pod.yaml` with a manifest that sets `kind` to |
| 178 | +Pod (unchanged), but with a revised `apiVersion`. |
| 179 | +--> |
| 180 | +`kubectl` 替换了 `pod.yaml` 的内容, |
| 181 | +在新的清单文件中,`kind` 被设置为 Pod(未变), |
| 182 | +但 `apiVersion` 则被修订了。 |
0 commit comments