Procedure  程序

When upgrading Rancher in an air-gapped environment, users who previously installed Rancher with helm template will encounter an "Error: UPGRADE FAILED: "rancher" has no deployed releases". This happens because helm template doesn't create a Helm release record in the cluster, which is essential for helm upgrade to function.
在空气隔离环境中升级 Rancher 时,之前用 helm 模板安装 Rancher 的用户会遇到“错误:升级失败:”rancher 没有部署版本“。这是因为 helm 模板不会在集群中创建 Helm 发布记录,而这对 helm 升级至关重要。

The standard solution provided in the Rancher documentation is to continue using the helm template method for subsequent upgrades. However, you may wish to migrate to the helm upgrade workflow, removing the additional step of templating the helm chart, before applying it with kubectl, during upgrades.
Rancher 文档中提供的标准解决方案是继续使用舵模板方法进行后续升级。不过,你可能想迁移到 Helm 升级流程,这样在升级时就不用再用 kubectl 模板化了 headm 图表。

helm upgrade --install can be used to upgrade the Rancher chart, whilst creating the necessary Helm release record in the cluster. However, attempting to use helm upgrade --install without taking ownership of existing resources will result in an error like the following, because the Kubernetes resources (such as PriorityClass) lack the necessary Helm labels (app.kubernetes.io/managed-by: Helm) and annotations (meta.helm.sh/release-name: rancher and meta.helm.sh/release-namespace: cattle-system).
helm upgrade --install 可用于升级 Rancher 图表,同时在集群中创建必要的 Helm 发布记录。然而,尝试使用 helm 升级——安装而不对现有资源拥有权,会导致如下错误,因为 Kubernetes 资源(如 PriorityClass)缺少必要的 Helm 标签( app.kubernetes.io/managed-by: Helm )和注释( meta.helm.sh/release-name: rancher meta.helm.sh/release-namespace: cattle-system 和 )。

<span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>helm upgrade --install rancher ./rancher-<VERSION>.tgz --namespace cattle-system --set hostname=<<a data-cke-saved-href="http://rancher.yourdomain.com/" href="http://rancher.yourdomain.com/">RANCHER.YOURDOMAIN.COM</a>>
Release "rancher" does not exist. Installing it now.
Error: Unable to continue with install: PriorityClass "rancher-critical" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "<a data-cke-saved-href="http://app.kubernetes.io/managed-by" href="http://app.kubernetes.io/managed-by">app.kubernetes.io/managed-by"</a>": must be set to "Helm"; annotation validation error: missing key "<a data-cke-saved-href="http://meta.helm.sh/release-name" href="http://meta.helm.sh/release-name">meta.helm.sh/release-name"</a>": must be set to "rancher"; annotation validation error: missing key "<a data-cke-saved-href="http://meta.helm.sh/release-namespace" href="http://meta.helm.sh/release-namespace">meta.helm.sh/release-namespace"</a>": must be set to "cattle-system"</code></span></span></span>

To migrate from the helm template workflow to the helm upgrade workflow, you must run the helm upgrade --install command with the --take-ownership flag. This flag instructs Helm to take control of existing resources in the cluster that were created by a previous installation of the same chart, even if they lack Helm-specific annotations and labels.
要从舵模板工作流程迁移到舵升级工作流,必须运行带有 --take-ownership 标志的 helm upgrade --install 命令。该标志指示 Helm 控制集群中由之前同一图表安装创建的现有资源,即使这些资源缺乏 Helm 专属的注释和标签。

This process essentially "adopts" the existing resources into a new Helm release, allowing future upgrades to be performed using the standard helm upgrade command.
该过程本质上将现有资源“采纳”到新的 Helm 版本中,允许未来通过标准 helm 升级命令进行升级。

Steps  步骤

  1. Navigate to the directory containing the Rancher Helm chart tarball.
    导航到包含 Rancher Helm 图表 tarball 的目录。

  2. Run the helm upgrade --install command with the --take-ownership flag, along with your original installation values (e.g., --set hostname):
    运行带有 --take-ownership 标志的 helm upgrade --install 命令,以及你的原始安装值(例如 --set 主机名 ):

    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>helm upgrade --install rancher ./rancher-<VERSION>.tgz --namespace cattle-system --set hostname=<<a data-cke-saved-href="http://rancher.yourdomain.com/" href="http://rancher.yourdomain.com/">RANCHER.YOURDOMAIN.COM</a>> --take-ownership</code></span></span></span>
  3. Confirm that the command output shows a successful deployment, with "Rancher Server has been installed":
    确认命令输出显示成功部署,并显示“Rancher Server 已安装”:
    <span style="color:#000000"><span style="background-color:#ffffff"><span style="background-color:#efefef"><code>Release "rancher" does not exist. Installing it now.
    NAME: rancher
    LAST DEPLOYED: Fri Aug 22 15:18:09 2025
    NAMESPACE: cattle-system
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    NOTES:
    Rancher Server has been installed.</code></span></span></span>
Environment  环境
  • Rancher Server installed in an air-gapped environment.
    Rancher 服务器安装在空气隔离环境中。
  • The initial installation was performed using the `helm template` command.
    初始安装使用“helm template”命令完成。

 访问Rancher-K8S解决方案博主,企业合作伙伴 :
https://blog.csdn.net/lidw2009

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐