|
| 1 | +--- |
| 2 | +title: 更改 Kubernetes 软件包仓库 |
| 3 | +content_type: task |
| 4 | +weight: 120 |
| 5 | +--- |
| 6 | +<!-- |
| 7 | +title: Changing The Kubernetes Package Repository |
| 8 | +content_type: task |
| 9 | +weight: 120 |
| 10 | +--> |
| 11 | + |
| 12 | +<!-- overview --> |
| 13 | + |
| 14 | +<!-- |
| 15 | +This page explains how to switch from one Kubernetes package repository to another |
| 16 | +when upgrading Kubernetes minor releases. Unlike deprecated Google-hosted |
| 17 | +repositories, the Kubernetes package repositories are structured in a way that |
| 18 | +there's a dedicated package repository for each Kubernetes minor version. |
| 19 | +--> |
| 20 | +本文阐述如何在升级 Kubernetes 小版本时从一个软件包仓库切换到另一个。 |
| 21 | +与弃用的 Google 托管仓库不同,Kubernetes 软件包仓库的结构是每个 Kubernetes |
| 22 | +小版本都有一个专门的软件包仓库。 |
| 23 | + |
| 24 | +## {{% heading "prerequisites" %}} |
| 25 | + |
| 26 | +<!-- |
| 27 | +This document assumes that you're already using the Kubernetes community-owned |
| 28 | +package repositories. If that's not the case, it's strongly recommend to migrate |
| 29 | +to the Kubernetes package repositories. |
| 30 | +--> |
| 31 | +本文假设你已经在使用 Kubernetes 社区所拥有的软件包仓库。 |
| 32 | +如果不是这种情况,强烈建议迁移到 Kubernetes 软件包仓库。 |
| 33 | + |
| 34 | +<!-- |
| 35 | +### Verifying if the Kubernetes package repositories are used |
| 36 | +
|
| 37 | +If you're unsure if you're using the Kubernetes package repositories or the |
| 38 | +Google-hosted repository, take the following steps to verify: |
| 39 | +--> |
| 40 | +### 验证是否正在使用 Kubernetes 软件包仓库 |
| 41 | + |
| 42 | +如果你不确定自己是在使用 Kubernetes 软件包仓库还是在使用 Google 托管的仓库, |
| 43 | +可以执行以下步骤进行验证: |
| 44 | + |
| 45 | +{{< tabs name="k8s_install_versions" >}} |
| 46 | +{{% tab name="Ubuntu、Debian 或 HypriotOS" %}} |
| 47 | + |
| 48 | +<!-- |
| 49 | +Print the contents of the file that defines the Kubernetes `apt` repository: |
| 50 | +
|
| 51 | +```shell |
| 52 | +# On your system, this configuration file could have a different name |
| 53 | +pager /etc/apt/sources.list.d/kubernetes.list |
| 54 | +``` |
| 55 | +
|
| 56 | +If you see a line similar to: |
| 57 | +--> |
| 58 | +打印定义 Kubernetes `apt` 仓库的文件的内容: |
| 59 | + |
| 60 | +```shell |
| 61 | +# 在你的系统上,此配置文件可能具有不同的名称 |
| 62 | +pager /etc/apt/sources.list.d/kubernetes.list |
| 63 | +``` |
| 64 | + |
| 65 | +如果你看到类似以下的一行: |
| 66 | + |
| 67 | +``` |
| 68 | +deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/deb/ / |
| 69 | +``` |
| 70 | + |
| 71 | +<!-- |
| 72 | +**You're using the Kubernetes package repositories and this guide applies to you.** |
| 73 | +Otherwise, it's strongly recommend to migrate to the Kubernetes package repositories. |
| 74 | +--> |
| 75 | +**你正在使用 Kubernetes 软件包仓库,本指南适用于你。** |
| 76 | +否则,强烈建议迁移到 Kubernetes 软件包仓库。 |
| 77 | + |
| 78 | +{{% /tab %}} |
| 79 | +{{% tab name="CentOS、RHEL 或 Fedora" %}} |
| 80 | + |
| 81 | +<!-- |
| 82 | +Print the contents of the file that defines the Kubernetes `yum` repository: |
| 83 | +
|
| 84 | +```shell |
| 85 | +# On your system, this configuration file could have a different name |
| 86 | +cat /etc/yum.repos.d/kubernetes.repo |
| 87 | +``` |
| 88 | +
|
| 89 | +If you see `baseurl` similar to the `baseurl` in the output below: |
| 90 | +--> |
| 91 | +打印定义 Kubernetes `yum` 仓库的文件的内容: |
| 92 | + |
| 93 | +```shell |
| 94 | +# 在你的系统上,此配置文件可能具有不同的名称 |
| 95 | +cat /etc/yum.repos.d/kubernetes.repo |
| 96 | +``` |
| 97 | + |
| 98 | +如果你看到的 `baseurl` 类似以下输出中的 `baseurl`: |
| 99 | + |
| 100 | +``` |
| 101 | +[kubernetes] |
| 102 | +name=Kubernetes |
| 103 | +baseurl=https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/rpm/ |
| 104 | +enabled=1 |
| 105 | +gpgcheck=1 |
| 106 | +gpgkey=https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/rpm/repodata/repomd.xml.key |
| 107 | +exclude=kubelet kubeadm kubectl |
| 108 | +``` |
| 109 | + |
| 110 | +<!-- |
| 111 | +**You're using the Kubernetes package repositories and this guide applies to you.** |
| 112 | +Otherwise, it's strongly recommend to migrate to the Kubernetes package repositories. |
| 113 | +--> |
| 114 | +**你正在使用 Kubernetes 软件包仓库,本指南适用于你。** |
| 115 | +否则,强烈建议迁移到 Kubernetes 软件包仓库。 |
| 116 | + |
| 117 | +{{% /tab %}} |
| 118 | +{{< /tabs >}} |
| 119 | + |
| 120 | +{{< note >}} |
| 121 | +<!-- |
| 122 | +The URL used for the Kubernetes package repositories is not limited to `pkgs.k8s.io`, |
| 123 | +it can also be one of: |
| 124 | +--> |
| 125 | +Kubernetes 软件包仓库所用的 URL 不仅限于 `pkgs.k8s.io`,还可以是以下之一: |
| 126 | + |
| 127 | +- `pkgs.k8s.io` |
| 128 | +- `pkgs.kubernetes.io` |
| 129 | +- `packages.kubernetes.io` |
| 130 | +{{</ note >}} |
| 131 | + |
| 132 | +<!-- steps --> |
| 133 | + |
| 134 | +<!-- |
| 135 | +## Switching to another Kubernetes package repository |
| 136 | +
|
| 137 | +This step should be done upon upgrading from one to another Kubernetes minor |
| 138 | +release in order to get access to the packages of the desired Kubernetes minor |
| 139 | +version. |
| 140 | +--> |
| 141 | +## 切换到其他 Kubernetes 软件包仓库 {#switching-to-another-kubernetes-package-repository} |
| 142 | + |
| 143 | +在从一个 Kubernetes 小版本升级到另一个版本时,应执行此步骤以获取所需 Kubernetes 小版本的软件包访问权限。 |
| 144 | + |
| 145 | +{{< tabs name="k8s_install_versions" >}} |
| 146 | +{{% tab name="Ubuntu、Debian 或 HypriotOS" %}} |
| 147 | + |
| 148 | +<!-- |
| 149 | +1. Open the file that defines the Kubernetes `apt` repository using a text editor of your choice: |
| 150 | +--> |
| 151 | +1. 使用你所选择的文本编辑器打开定义 Kubernetes `apt` 仓库的文件: |
| 152 | + |
| 153 | + ```shell |
| 154 | + nano /etc/apt/sources.list.d/kubernetes.list |
| 155 | + ``` |
| 156 | + |
| 157 | + <!-- |
| 158 | + You should see a single line with the URL that contains your current Kubernetes |
| 159 | + minor version. For example, if you're using v{{< skew currentVersionAddMinor -1 "." >}}, |
| 160 | + you should see this: |
| 161 | + --> |
| 162 | + 你应该看到一行包含当前 Kubernetes 小版本的 URL。 |
| 163 | + 例如,如果你正在使用 v{{< skew currentVersionAddMinor -1 "." >}},你应该看到类似以下的输出: |
| 164 | + |
| 165 | + ``` |
| 166 | + deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/deb/ / |
| 167 | + ``` |
| 168 | + |
| 169 | +<!-- |
| 170 | +2. Change the version in the URL to **the next available minor release**, for example: |
| 171 | +--> |
| 172 | +2. 将 URL 中的版本更改为**下一个可用的小版本**,例如: |
| 173 | + |
| 174 | + ``` |
| 175 | + deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/deb/ / |
| 176 | + ``` |
| 177 | + |
| 178 | +<!-- |
| 179 | +3. Save the file and exit your text editor. Continue following the relevant upgrade instructions. |
| 180 | +--> |
| 181 | +3. 保存文件并退出文本编辑器。继续按照相关的升级说明进行操作。 |
| 182 | + |
| 183 | +{{% /tab %}} |
| 184 | +{{% tab name="CentOS、RHEL 或 Fedora" %}} |
| 185 | + |
| 186 | +<!-- |
| 187 | +1. Open the file that defines the Kubernetes `yum` repository using a text editor of your choice: |
| 188 | +--> |
| 189 | +1. 使用你所选择的文本编辑器打开定义 Kubernetes `yum` 仓库的文件: |
| 190 | + |
| 191 | + ```shell |
| 192 | + nano /etc/yum.repos.d/kubernetes.repo |
| 193 | + ``` |
| 194 | + |
| 195 | + <!-- |
| 196 | + You should see a file with two URLs that contain your current Kubernetes |
| 197 | + minor version. For example, if you're using v{{< skew currentVersionAddMinor -1 "." >}}, |
| 198 | + you should see this: |
| 199 | + --> |
| 200 | + 你应该看到一个文件包含当前 Kubernetes 小版本的两个 URL。 |
| 201 | + 例如,如果你正在使用 v{{< skew currentVersionAddMinor -1 "." >}},你应该看到类似以下的输出: |
| 202 | + |
| 203 | + ``` |
| 204 | + [kubernetes] |
| 205 | + name=Kubernetes |
| 206 | + baseurl=https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/rpm/ |
| 207 | + enabled=1 |
| 208 | + gpgcheck=1 |
| 209 | + gpgkey=https://pkgs.k8s.io/core:/stable:/v{{< skew currentVersionAddMinor -1 "." >}}/rpm/repodata/repomd.xml.key |
| 210 | + exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni |
| 211 | + ``` |
| 212 | + |
| 213 | +<!-- |
| 214 | +2. Change the version in these URLs to **the next available minor release**, for example: |
| 215 | +--> |
| 216 | +2. 将这些 URL 中的版本更改为**下一个可用的小版本**,例如: |
| 217 | + |
| 218 | + ``` |
| 219 | + [kubernetes] |
| 220 | + name=Kubernetes |
| 221 | + baseurl=https://pkgs.k8s.io/core:/stable:/v{{< param "version" >}}/rpm/ |
| 222 | + enabled=1 |
| 223 | + gpgcheck=1 |
| 224 | + gpgkey=https://pkgs.k8s.io/core:/stable:/v{{< param "version" >}}/rpm/repodata/repomd.xml.key |
| 225 | + exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni |
| 226 | + ``` |
| 227 | + |
| 228 | +<!-- |
| 229 | +3. Save the file and exit your text editor. Continue following the relevant upgrade instructions. |
| 230 | +--> |
| 231 | +3. 保存文件并退出文本编辑器。继续按照相关的升级说明进行操作。 |
| 232 | + |
| 233 | +{{% /tab %}} |
| 234 | +{{< /tabs >}} |
| 235 | + |
| 236 | +## {{% heading "whatsnext" %}} |
| 237 | + |
| 238 | +<!-- |
| 239 | +* See how to [Upgrade Linux nodes](/docs/tasks/administer-cluster/kubeadm/upgrading-linux-nodes/). |
| 240 | +* See how to [Upgrade Windows nodes](/docs/tasks/administer-cluster/kubeadm/upgrading-windows-nodes/). |
| 241 | +--> |
| 242 | +* 参见如何[升级 Linux 节点的说明](/zh-cn/docs/tasks/administer-cluster/kubeadm/upgrading-linux-nodes/)。 |
| 243 | +* 参见如何[升级 Windows 节点的说明](/zh-cn/docs/tasks/administer-cluster/kubeadm/upgrading-windows-nodes/)。 |
0 commit comments