1.6. 回滚 Operator 升级


要回滚 Operator 升级,您必须执行以下部分之一中描述的步骤。您可以使用 CLI 或 OpenShift Container Platform Web 控制台回滚 Operator 升级。

注意

如果您要从 RHACS 4.0 回滚,则只能回滚到 RHACS 3.74 的最新补丁版本。

1.6.1. 使用 CLI 回滚 Operator 升级

您可以使用 CLI 命令回滚 Operator 版本。

流程

  1. 运行以下命令来删除 OLM 订阅:

    • 对于 OpenShift Container Platform,运行以下命令:

      $ oc -n rhacs-operator delete subscription rhacs-operator
    • 对于 Kubernetes,运行以下命令:

      $ kubectl -n rhacs-operator delete subscription rhacs-operator
  2. 运行以下命令来删除集群服务版本(CSV):

    • 对于 OpenShift Container Platform,运行以下命令:

      $ oc -n rhacs-operator delete csv -l operators.coreos.com/rhacs-operator.rhacs-operator
    • 对于 Kubernetes,运行以下命令:

      $ kubectl -n rhacs-operator delete csv -l operators.coreos.com/rhacs-operator.rhacs-operator
  3. 选择以下选项之一来确定您要回滚到的以前的版本:

    • 如果当前 Central 实例正在运行,请运行以下命令查询 RHACS API 以获取回滚版本:

      $ curl -k -s -u <user>:<password> https://<central hostname>/v1/centralhealth/upgradestatus | jq -r .upgradeStatus.forceRollbackTo
    • 如果当前 Central 实例没有运行,请执行以下步骤:

      注意

      当安装了 rocksdb 数据库时,这个步骤只能用于 RHACS 版本 3.74 及更早版本。

      1. 运行以下命令,确保 Central 部署已缩减:

        • 对于 OpenShift Container Platform,运行以下命令:

          $ oc scale -n <central namespace> –replicas=0 deploy/central
        • 对于 Kubernetes,运行以下命令:

          $ kubectl scale -n <central namespace> –replicas=0 deploy/central
      2. 将以下 pod spec 保存为 YAML 文件:

        apiVersion: v1
        kind: Pod
        metadata:
          name: get-previous-db-version
        spec:
          containers:
          - name: get-previous-db-version
            image: registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:<rollback version>
            command:
            - sh
            args:
            - '-c'
            - "cat /var/lib/stackrox/.previous/migration_version.yaml | grep '^image:' | cut -f 2 -d : | tr -d ' '"
            volumeMounts:
            - name: stackrox-db
              mountPath: /var/lib/stackrox
          volumes:
          - name: stackrox-db
            persistentVolumeClaim:
              claimName: stackrox-db
      3. 使用您保存的 YAML 文件,在 Central 命名空间中创建 pod:

        • 对于 OpenShift Container Platform,运行以下命令:

          $ oc create -n <central namespace> -f pod.yaml
        • 对于 Kubernetes,运行以下命令:

          $ kubectl create -n <central namespace> -f pod.yaml
      4. 创建 pod 后,运行以下命令来获取版本:

        • 对于 OpenShift Container Platform,运行以下命令:

          $ oc logs -n <central namespace> get-previous-db-version
        • 对于 Kubernetes,运行以下命令:

          $ kubectl logs -n <central namespace> get-previous-db-version
  4. 运行以下命令,编辑 central-config.yaml ConfigMap 来设置 maintenance.forceRollBackVersion:<version > 参数:

    • 对于 OpenShift Container Platform,运行以下命令:

      $ oc get configmap -n <central namespace> central-config -o yaml | sed -e "s/forceRollbackVersion: none/forceRollbackVersion: <version>/" | oc -n <central namespace> apply -f -
    • 对于 Kubernetes,运行以下命令:

      $ kubectl get configmap -n <central namespace> central-config -o yaml | sed -e "s/forceRollbackVersion: none/forceRollbackVersion: <version>/" | kubectl -n <central namespace> apply -f -
  5. 使用第 3 步作为镜像标签中显示的版本字符串为 Central 部署设置镜像。例如,运行以下命令:

    • 对于 OpenShift Container Platform,运行以下命令:

      $ oc set image -n <central namespace> deploy/central central=registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:<version>
    • 对于 Kubernetes,运行以下命令:

      $ kubectl set image -n <central namespace> deploy/central central=registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:<version>

验证

  1. 确保 Central pod 已启动并处于 ready 状态。如果 pod 崩溃,请检查日志以查看备份是否已恢复。此时会出现成功日志消息类似以下示例:

    Clone to Migrate ".previous", ""
  2. 在滚动频道上重新安装 Operator。例如,3.74.2 安装在 rhacs-3.74 频道中。

1.6.2. 使用 Web 控制台回滚 Operator 升级

您可以使用 OpenShift Container Platform Web 控制台回滚 Operator 版本。

先决条件

  • 您可以使用具有 cluster-admin 权限的账户访问 OpenShift Container Platform 集群 Web 控制台。

流程

  1. 进入到 Operators Installed Operators 页面。
  2. 找到 RHACS Operator 并点它。
  3. Operator Details 页面中,从 Actions 列表中选择 Uninstall Operator。按照此操作,Operator 将停止运行,不再接收更新。
  4. 选择以下选项之一来确定您要回滚到的以前的版本:

    • 如果当前 Central 实例正在运行,您可以从终端窗口中运行以下命令来查询 RHACS API 以获取回滚版本:

      $ curl -k -s -u <user>:<password> https://<central hostname>/v1/centralhealth/upgradestatus | jq -r .upgradeStatus.forceRollbackTo
    • 您可以通过执行以下步骤来创建 pod 并提取之前的版本:

      注意

      当安装了 rocksdb 数据库时,这个步骤只能用于 RHACS 版本 3.74 及更早版本。

      1. 导航到 Workloads Deployments central
      2. Deployment details 下,单击 pod 计数旁边的向下箭头来缩减 pod。
      3. 导航到 Workloads Pods Create Pod,并将 pod 规格的内容粘贴到编辑器中:

        apiVersion: v1
        kind: Pod
        metadata:
          name: get-previous-db-version
        spec:
          containers:
          - name: get-previous-db-version
            image: registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:<rollback version>
            command:
            - sh
            args:
            - '-c'
            - "cat /var/lib/stackrox/.previous/migration_version.yaml | grep '^image:' | cut -f 2 -d : | tr -d ' '"
            volumeMounts:
            - name: stackrox-db
              mountPath: /var/lib/stackrox
          volumes:
          - name: stackrox-db
            persistentVolumeClaim:
              claimName: stackrox-db
      4. Create
      5. 创建 pod 后,点 Logs 选项卡获取版本字符串。
  5. 通过执行以下步骤来更新回滚配置:

    1. 导航到 Workloads ConfigMaps central-config,然后从 Actions 列表中选择 Edit ConfigMap
    2. central-config.yaml 键的值中找到 forceRollbackVersion 行。
    3. none 替换为 3.73.3,然后保存文件。
  6. 通过执行以下步骤将 Central 更新至更早的版本:

    1. 导航到 Workloads Deployments central,然后从 Actions 列表中选择 Edit Deployment
    2. 更新镜像名称,然后保存更改。

验证

  1. 确保 Central pod 已启动并处于 ready 状态。如果 pod 崩溃,请检查日志以查看备份是否已恢复。此时会出现成功日志消息类似以下示例:

    Clone to Migrate ".previous", ""
  2. 在滚动频道上重新安装 Operator。例如,3.74.2 安装在 rhacs-3.74 频道中。
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部