第1章 Operator を使用したアップグレード

Red Hat Advanced Cluster Security for Kubernetes (RHACS) Operator を介したアップグレードは、インストール時に選択した Update approval オプションに応じて、自動または手動で実行されます。

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 バージョンをロールバックできます。

手順

  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 namespace に 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.71.3rhacs-3.71 チャネルにインストールされます。