第 1 章 使用 Operator 升级
根据安装时选择的 Update approval 选项,通过 Red Hat Advanced Cluster Security for Kubernetes (RHACS) Operator 自动执行或手动升级。
如果您使用 Operator 安装 RHACS 并在 Update approval 字段中选择 Automatic,则当发布新的软件版本时,RHACS 会被自动更新。如果选择了 Manual,则必须使用 Operator Lifecycle Manager (OLM)批准后续的 Operator 更新。如需更多信息,请参阅 手动批准待处理的 Operator 更新。
要回滚 Operator 升级,您必须执行以下部分中描述的步骤。您可以使用 CLI 或 OpenShift Container Platform Web 控制台回滚 Operator 升级。
1.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 规格保存为 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 -
使用 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>
验证
确保 Central pod 启动并处于
ready状态。如果 pod 崩溃,请检查日志以查看备份是否已恢复。一个成功的日志消息类似以下示例:Clone to Migrate ".previous", ""
-
在回滚频道上重新安装 Operator。例如,
3.71.3在rhacs-3.71频道中安装。