1.5. Operator アップグレードのロールバック
Operator アップグレードをロールバックするには、次のセクションのいずれかで説明されている手順を実行する必要があります。CLI または OpenShift Container Platform Web コンソールを使用して、Operator アップグレードをロールバックできます。
RHACS 4.0 からロールバックする場合は、RHACS 3.74 の最新パッチリリースバージョンにのみロールバックできます。
1.5.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 namespace に 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.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 -
ステップ 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.5.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
チャネルにインストールされます。