1.6. 回滚 Operator 升级
要回滚 Operator 升级,您必须执行以下部分之一中描述的步骤。您可以使用 CLI 或 OpenShift Container Platform Web 控制台回滚 Operator 升级。
如果您要从 RHACS 4.0 回滚,则只能回滚到 RHACS 3.74 的最新补丁版本。
1.6.1. 使用 CLI 回滚 Operator 升级 复制链接链接已复制到粘贴板!
您可以使用 CLI 命令回滚 Operator 版本。
流程
运行以下命令来删除 OLM 订阅:
对于 OpenShift Container Platform,运行以下命令:
$ oc -n rhacs-operator delete subscription rhacs-operator对于 Kubernetes,运行以下命令:
$ kubectl -n rhacs-operator delete subscription rhacs-operator
运行以下命令来删除集群服务版本(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
选择以下选项之一来确定您要回滚到的以前的版本:
如果当前 Central 实例正在运行,请运行以下命令查询 RHACS API 以获取回滚版本:
$ curl -k -s -u <user>:<password> https://<central hostname>/v1/centralhealth/upgradestatus | jq -r .upgradeStatus.forceRollbackTo如果当前 Central 实例没有运行,请执行以下步骤:
注意当安装了
rocksdb数据库时,这个步骤只能用于 RHACS 版本 3.74 及更早版本。运行以下命令,确保 Central 部署已缩减:
对于 OpenShift Container Platform,运行以下命令:
$ oc scale -n <central namespace> –replicas=0 deploy/central对于 Kubernetes,运行以下命令:
$ kubectl scale -n <central namespace> –replicas=0 deploy/central
将以下 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使用您保存的 YAML 文件,在 Central 命名空间中创建 pod:
对于 OpenShift Container Platform,运行以下命令:
$ oc create -n <central namespace> -f pod.yaml对于 Kubernetes,运行以下命令:
$ kubectl create -n <central namespace> -f pod.yaml
创建 pod 后,运行以下命令来获取版本:
对于 OpenShift Container Platform,运行以下命令:
$ oc logs -n <central namespace> get-previous-db-version对于 Kubernetes,运行以下命令:
$ kubectl logs -n <central namespace> get-previous-db-version
运行以下命令,编辑
central-config.yamlConfigMap来设置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 -
使用第 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>
验证
确保 Central pod 已启动并处于
ready状态。如果 pod 崩溃,请检查日志以查看备份是否已恢复。此时会出现成功日志消息类似以下示例:Clone to Migrate ".previous", ""-
在滚动频道上重新安装 Operator。例如,
3.74.2安装在rhacs-3.74频道中。
1.6.2. 使用 Web 控制台回滚 Operator 升级 复制链接链接已复制到粘贴板!
您可以使用 OpenShift Container Platform Web 控制台回滚 Operator 版本。
先决条件
-
您可以使用具有
cluster-admin权限的账户访问 OpenShift Container Platform 集群 Web 控制台。
流程
-
进入到 Operators
Installed Operators 页面。 - 找到 RHACS Operator 并点它。
- 在 Operator Details 页面中,从 Actions 列表中选择 Uninstall Operator。按照此操作,Operator 将停止运行,不再接收更新。
选择以下选项之一来确定您要回滚到的以前的版本:
如果当前 Central 实例正在运行,您可以从终端窗口中运行以下命令来查询 RHACS API 以获取回滚版本:
$ curl -k -s -u <user>:<password> https://<central hostname>/v1/centralhealth/upgradestatus | jq -r .upgradeStatus.forceRollbackTo您可以通过执行以下步骤来创建 pod 并提取之前的版本:
注意当安装了
rocksdb数据库时,这个步骤只能用于 RHACS 版本 3.74 及更早版本。-
导航到 Workloads
Deployments central。 - 在 Deployment details 下,单击 pod 计数旁边的向下箭头来缩减 pod。
导航到 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- 点 Create。
- 创建 pod 后,点 Logs 选项卡获取版本字符串。
-
导航到 Workloads
通过执行以下步骤来更新回滚配置:
-
导航到 Workloads
ConfigMaps central-config,然后从 Actions 列表中选择 Edit ConfigMap。 -
在
central-config.yaml键的值中找到forceRollbackVersion行。 -
将
none替换为3.73.3,然后保存文件。
-
导航到 Workloads
通过执行以下步骤将 Central 更新至更早的版本:
-
导航到 Workloads
Deployments central,然后从 Actions 列表中选择 Edit Deployment。 - 更新镜像名称,然后保存更改。
-
导航到 Workloads
验证
确保 Central pod 已启动并处于
ready状态。如果 pod 崩溃,请检查日志以查看备份是否已恢复。此时会出现成功日志消息类似以下示例:Clone to Migrate ".previous", ""-
在滚动频道上重新安装 Operator。例如,
3.74.2安装在rhacs-3.74频道中。