You are viewing documentation for a release that is no longer maintained. To view the documentation for the most recent version, see the latest RHACS docs.
2.2. Central クラスターのアップグレード
Central データベースをバックアップしたら、次のステップは Central クラスターをアップグレードすることです。この手順には、Central、roxctl
CLI、および Scanner のアップグレードが含まれます。
2.2.1. Central のアップグレード
更新されたイメージをダウンロードしてデプロイすることにより、Central を最新バージョンに更新できます。
前提条件
- プライベートイメージレジストリーからイメージをデプロイする場合は、最初に新しいイメージをプライベートレジストリーにプッシュしてから、このセクションのコマンドのイメージレジストリーを置き換えます。
手順
次のコマンドを実行して、Central をアップグレードします。
$ oc -n stackrox patch deploy/central -p '{"spec":{"template":{"spec":{"containers":[{"name":"central","env":[{"name":"ROX_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}]}]}}}}' 1
- 1
- Kubernetes を使用する場合は、
oc
の代わりにkubectl
と入力します。
$ oc -n stackrox patch deployment/scanner -p '{"spec":{"template":{"spec":{"containers":[{"name":"scanner","securityContext":{"runAsUser":65534}}]}}}}' 1
- 1
- Kubernetes を使用する場合は、
oc
の代わりにkubectl
と入力します。
$ oc -n stackrox set image deploy/central central=registry.redhat.io/advanced-cluster-security/rhacs-main-rhel8:3.71.3 1
- 1
- Kubernetes を使用する場合は、
oc
の代わりにkubectl
と入力します。
重要Red Hat Advanced Cluster Security for Kubernetes 3.65.0 からアップグレードする場合は、次の追加コマンドを実行して、
stackrox-central-diagnostics
ロールを作成する必要があります。$ oc -n stackrox patch role stackrox-central-diagnostics -p '{"rules":[{"apiGroups":["*"],"resources":["deployments","daemonsets","replicasets","configmaps","services"],"verbs":["get","list"]}]}' 1
- 1
- Kubernetes を使用する場合は、
oc
の代わりにkubectl
と入力します。
Helm または Operator を使用して Red Hat Advanced Cluster Security for Kubernetes をインストールしておらず、OpenShift OAuth サーバーを使用して認証を有効にする場合は、次の追加コマンドを実行する必要があります。
$ oc -n stackrox set env deploy/central ROX_ENABLE_OPENSHIFT_AUTH=true
$ oc -n stackrox patch serviceaccount/central -p ' { "metadata": { "annotations": { "serviceaccounts.openshift.io/oauth-redirecturi.main": "sso/providers/openshift/callback", "serviceaccounts.openshift.io/oauth-redirectreference.main": "{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"central"}}" } } }'
2.2.2. roxctl CLI のアップグレード
roxctl
CLI を最新バージョンにアップグレードするには、既存のバージョンの roxctl
CLI をアンインストールしてから、最新バージョンの roxctl
CLI をインストールする必要があります。
2.2.2.1. roxctl CLI のアンインストール
次の手順を使用して、Linux に roxctl
CLI バイナリーをアンインストールできます。
手順
roxctl
バイナリーを見つけて削除します。$ ROXPATH=$(which roxctl) && rm -f $ROXPATH 1
- 1
- 環境によっては、
roxctl
バイナリーを削除するために管理者権限が必要になる場合があります。
2.2.2.2. Linux への roxctl CLI のインストール
次の手順を使用して、Linux に roxctl
CLI バイナリーをインストールできます。
手順
roxctl
CLI の最新バージョンをダウンロードします。$ curl -O https://mirror.openshift.com/pub/rhacs/assets/3.71.3/bin/Linux/roxctl
roxctl
バイナリーを実行可能にします。$ chmod +x roxctl
PATH
上にあるディレクトリーにroxctl
バイナリーを配置します。PATH
を確認するには、以下のコマンドを実行します。$ echo $PATH
検証
インストールした
roxctl
のバージョンを確認します。$ roxctl version
2.2.2.3. macOS への roxctl CLI のインストール
次の手順を使用して、roxctl
CLI バイナリーを macOS にインストールできます。
手順
roxctl
CLI の最新バージョンをダウンロードします。$ curl -O https://mirror.openshift.com/pub/rhacs/assets/3.71.3/bin/Darwin/roxctl
バイナリーからすべての拡張属性を削除します。
$ xattr -c roxctl
roxctl
バイナリーを実行可能にします。$ chmod +x roxctl
PATH
上にあるディレクトリーにroxctl
バイナリーを配置します。PATH
を確認するには、以下のコマンドを実行します。$ echo $PATH
検証
インストールした
roxctl
のバージョンを確認します。$ roxctl version
2.2.2.4. Windows への roxctl CLI のインストール
次の手順を使用して、roxctl
CLI バイナリーを Windows にインストールできます。
手順
roxctl
CLI の最新バージョンをダウンロードします。$ curl -O https://mirror.openshift.com/pub/rhacs/assets/3.71.3/bin/Windows/roxctl.exe
検証
インストールした
roxctl
のバージョンを確認します。$ roxctl version
roxctl
CLI をアップグレードした後、Scanner をアップグレードできます。
2.2.3. Scanner のアップグレード
roxctl
CLI を使用して、Scanner を最新バージョンに更新できます。
前提条件
- プライベートイメージレジストリーからイメージをデプロイする場合は、最初に新しいイメージをプライベートレジストリーにプッシュしてから、次のセクションのコマンドを編集して、プライベートイメージレジストリーの名前を使用する必要があります。
手順
カスタムスキャナー設定を作成した場合は、スキャナー設定ファイルを更新する前に、これらの変更を適用する必要があります。
次の
roxctl
コマンドを使用してスキャナーを生成します。$ roxctl -e "$ROX_CENTRAL_ADDRESS" scanner generate
TLS シークレット YAML ファイルを適用します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc apply -f scanner-bundle/scanner/02-scanner-03-tls-secret.yaml
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl apply -f scanner-bundle/scanner/02-scanner-03-tls-secret.yaml
スキャナー設定 YAML ファイルを適用します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc apply -f scanner-bundle/scanner/02-scanner-04-scanner-config.yaml
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl apply -f scanner-bundle/scanner/02-scanner-04-scanner-config.yaml
Scanner イメージを更新します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc -n stackrox set image deploy/scanner scanner=registry.redhat.io/advanced-cluster-security/rhacs-scanner-rhel8:3.71.3
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl -n stackrox set image deploy/scanner scanner=registry.redhat.io/advanced-cluster-security/rhacs-scanner-rhel8:3.71.3
Scanner データベースイメージを更新します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc -n stackrox set image deploy/scanner-db db=registry.redhat.io/advanced-cluster-security/rhacs-scanner-db-rhel8:3.71.3 init-db=registry.redhat.io/advanced-cluster-security/rhacs-scanner-db-rhel8:3.71.3
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl -n stackrox set image deploy/scanner-db db=registry.redhat.io/advanced-cluster-security/rhacs-scanner-db-rhel8:3.71.3 init-db=registry.redhat.io/advanced-cluster-security/rhacs-scanner-db-rhel8:3.71.3
検証
新しい Pod が正常にデプロイされたことを確認します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc get pod -n stackrox --watch
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl get pod -n stackrox --watch
2.2.3.1. RHACS バージョン 3.71 へのアップグレード
roxctl
CLI および YAML ファイルを使用して RHACS 3.71 にアップグレードする場合は、いくつかの追加手順を実行する必要があります。Scanner DB イメージは、scanner-db-password
Kubernetes Secret を db
Scanner DB コンテナーにマウントしなくなりました。代わりに、scanner-db-password
は init コンテナー init-db
でのみ使用されます。したがって、POSTGRES_PASSWORD_FILE
環境変数を init コンテナー設定に追加する必要があります。init コンテナーは、scanner-db-tls-volume
および scanner-db-password
ボリュームもマウントする必要があります。以下のセクションでは、OpenShift Container Platform または Kubernetes を使用している場合の RHACS のアップグレード手順を説明します。init コンテナーの詳細については、Kubernetes のドキュメント を参照してください。
前提条件
-
この手順では、Scanner DB 設定の
db
コンテナーがindex 0
にあると想定している。これは、containers
リストの最初のエントリーである。また、scanner-db-password
ボリュームマウントは、3 番目のエントリーであるindex 2
にある。
このシナリオはほとんどの展開に当てはまりますが、これらのコマンドを入力する前に Scanner DB の設定を確認してください。値が異なる場合は、次のコマンドで …/containers/x/volumeMounts/y
の値を調整する必要があります。
手順
パッチを適用します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc -n stackrox patch deployment.apps/scanner-db --patch '{"spec":{"template":{"spec":{"initContainers":[{"name":"init-db","env":[{"name":"POSTGRES_PASSWORD_FILE","value":"/run/secrets/stackrox.io/secrets/password"}],"command":["/usr/local/bin/docker-entrypoint.sh","postgres","-c","config_file=/etc/postgresql.conf"],"volumeMounts":[{"name":"db-data","mountPath":"/var/lib/postgresql/data"},{"name":"scanner-db-tls-volume","mountPath":"/run/secrets/stackrox.io/certs","readOnly":true},{"name":"scanner-db-password","mountPath":"/run/secrets/stackrox.io/secrets","readOnly":true}],"securityContext":{"runAsGroup":70,"runAsNonRoot":true,"runAsUser":70}}]}}}}'
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl -n stackrox patch deployment.apps/scanner-db --patch '{"spec":{"template":{"spec":{"initContainers":[{"name":"init-db","env":[{"name":"POSTGRES_PASSWORD_FILE","value":"/run/secrets/stackrox.io/secrets/password"}],"command":["/usr/local/bin/docker-entrypoint.sh","postgres","-c","config_file=/etc/postgresql.conf"],"volumeMounts":[{"name":"db-data","mountPath":"/var/lib/postgresql/data"},{"name":"scanner-db-tls-volume","mountPath":"/run/secrets/stackrox.io/certs","readOnly":true},{"name":"scanner-db-password","mountPath":"/run/secrets/stackrox.io/secrets","readOnly":true}],"securityContext":{"runAsGroup":70,"runAsNonRoot":true,"runAsUser":70}}]}}}}'
パスを削除します。
OpenShift Container Platform を使用する場合は、以下のコマンドを入力します。
$ oc -n stackrox patch deployment.apps/scanner-db --type json --patch '[{"op":"remove","path":"/spec/template/spec/containers/0/volumeMounts/2"}]'
Kubernetes を使用する場合は、次のコマンドを入力します。
$ kubectl -n stackrox patch deployment.apps/scanner-db --type json --patch '[{"op":"remove","path":"/spec/template/spec/containers/0/volumeMounts/2"}]'
2.2.4. Central クラスターのアップグレードの確認
Central と Scanner の両方をアップグレードした後、Central クラスターのアップグレードが完了していることを確認します。
手順
Central ログを確認します。
OpenShift Container Platform を使用している場合は、次のコマンドを入力します。
$ oc logs -n stackrox deploy/central -c central
Kubernetes を使用している場合は、次のコマンドを入力します。
$ kubectl logs -n stackrox deploy/central -c central
正常なアップグレードのサンプル出力
No database restore directory found (this is not an error). Migrator: 2019/10/25 17:58:54: starting DB compaction Migrator: 2019/10/25 17:58:54: Free fraction of 0.0391 (40960/1048576) is < 0.7500. Will not compact badger 2019/10/25 17:58:54 INFO: All 1 tables opened in 2ms badger 2019/10/25 17:58:55 INFO: Replaying file id: 0 at offset: 846357 badger 2019/10/25 17:58:55 INFO: Replay took: 50.324µs badger 2019/10/25 17:58:55 DEBUG: Value log discard stats empty Migrator: 2019/10/25 17:58:55: DB is up to date. Nothing to do here. badger 2019/10/25 17:58:55 INFO: Got compaction priority: {level:0 score:1.73 dropPrefix:[]} version: 2019/10/25 17:58:55.189866 ensure.go:49: Info: Version found in the DB was current. We’re good to go!