手动升级
你可以使用安装脚本升级 K3s,也可以手动安装所需版本的二进制文件。
升级时会先升级 Server 节点,然后再升级 Agent 节点。 |
版本 Channels
通过安装脚本或使用我们的自动升级功能执行的升级可以绑定到不同的版本 channels。以下是可用的 channels:
Channel | 描述 |
---|---|
stable |
(默认)生产环境建议使用稳定版。这些版本已经过一段时间的社区强化。 |
latest |
建议使用最新版本来试用最新功能。这些版本已经过一段时间的社区强化。 |
v1.26(示例) |
每个 Kubernetes 次要版本都有一个 release channel,包括 EOL 的版本。这些 channel 会选择可用的最新补丁,不一定是稳定版本。 |
有关详细的最新 channel 列表,你可以访问 k3s channel 服务 API。有关 channel 如何工作的更多信息,请参阅 channelserver 项目。
尝试升级到 K3s 新版本时,https://kubernetes.io/docs/setup/release/version-skew-policy/[Kubernetes 版本倾斜策略]适用。确保你的计划在升级时不会跳过中间次要版本。system-upgrade-controller 本身不会防止更改到不支持的 Kubernetes 版本。 |
使用安装脚本升级 K3s
要升级旧版本的 K3s,你可以使用最初运行安装脚本时使用的相同配置选项重新运行安装脚本。
安装脚本使用 配置文件 的内容不受安装脚本管理。 要让你的配置独立于安装脚本,请使用配置文件而不是传递环境变量或使用安装脚本参数。 |
Running the install script will:
-
Download the new k3s binary
-
Update the systemd unit or openrc init script to reflect the args passed to the install script
-
Restart the k3s service
例如,要升级到当前的稳定版本:
curl -sfL https://get.k3s.io | <EXISTING_K3S_ENV> sh -s - <EXISTING_K3S_ARGS>
如果想升级到特定 channel(如 latest)中的更新版本,你可以指定 channel:
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL=latest <EXISTING_K3S_ENV> sh -s - <EXISTING_K3S_ARGS>
如果要升级到特定版本,可以运行以下命令:
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=vX.Y.Z+k3s1 <EXISTING_K3S_ENV> sh -s - <EXISTING_K3S_ARGS>
If you want to download the new version of k3s, but not start it, you can use the |
Upgrade K3s Using the Binary
To upgrade K3s manually, you can download the desired version of the K3s binary and replace the existing binary with the new one.
-
Download the desired version of the K3s binary from releases
-
Copy the downloaded binary to
/usr/local/bin/k3s
(or your desired location) -
Restart the k3s or k3s-agent service or restart the k3s process (binary)