1.5. 回滚 Operator 升级


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

注意

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

1.5.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 规格保存为 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. 使用 Step 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.5.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.74.3,然后保存文件。
  6. 通过执行以下步骤将 Central 更新至早期版本:

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

验证

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

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

学习

尝试、购买和销售

社区

關於紅帽

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

让开源更具包容性

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

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部