15.2.4. Lifecycle Agent を使用したイメージベースアップグレード用の ConfigMap オブジェクトの作成
Lifecycle Agent では、イメージベースアップグレード用に処理するために、すべての OADP リソース、追加のマニフェスト、およびカスタムカタログソースが ConfigMap オブジェクトにラップされている必要があります。
15.2.4.1. Lifecycle Agent を使用したイメージベースアップグレード用の OADP ConfigMap オブジェクトの作成 リンクのコピーリンクがクリップボードにコピーされました!
アップグレード中にリソースをバックアップおよび復元するために使用される OADP リソースを作成します。
前提条件
- 互換性のあるシードクラスターからシードイメージを生成した。
- OADP のバックアップおよび復元リソースを作成した。
- stateroot 間で共有されるコンテナーイメージ用に、ターゲットクラスターに個別のパーティションを作成した。詳細は、「イメージベースアップグレード用の共有コンテナーパーティションの設定」を参照してください。
- シードイメージで使用されるバージョンと互換性のあるバージョンの Lifecycle Agent をデプロイした。
-
OADP Operator、
DataProtectionApplicationCR、およびそのシークレットをターゲットクラスターにインストールした。 - S3 互換のストレージソリューションとすぐに使用できるバケットを作成し、適切な認証情報を設定した。詳細は、「OADP のインストールについて」を参照してください。
手順
OADP Operator がインストールされているのと同じ namespace (
openshift-adp) に、プラットフォームアーティファクトの OADPBackupCR およびRestoreCR を作成します。ターゲットクラスターが RHACM によって管理されている場合は、RHACM アーティファクトをバックアップおよび復元するために次の YAML ファイルを追加します。
RHACM 用の PlatformBackupRestore.yaml
apiVersion: velero.io/v1 kind: Backup metadata: name: acm-klusterlet annotations: lca.openshift.io/apply-label: "apps/v1/deployments/open-cluster-management-agent/klusterlet,v1/secrets/open-cluster-management-agent/bootstrap-hub-kubeconfig,rbac.authorization.k8s.io/v1/clusterroles/klusterlet,v1/serviceaccounts/open-cluster-management-agent/klusterlet,scheduling.k8s.io/v1/priorityclasses/klusterlet-critical,rbac.authorization.k8s.io/v1/clusterroles/open-cluster-management:klusterlet-admin-aggregate-clusterrole,rbac.authorization.k8s.io/v1/clusterrolebindings/klusterlet,operator.open-cluster-management.io/v1/klusterlets/klusterlet,apiextensions.k8s.io/v1/customresourcedefinitions/klusterlets.operator.open-cluster-management.io,v1/secrets/open-cluster-management-agent/open-cluster-management-image-pull-credentials"1 labels: velero.io/storage-location: default namespace: openshift-adp spec: includedNamespaces: - open-cluster-management-agent includedClusterScopedResources: - klusterlets.operator.open-cluster-management.io - clusterroles.rbac.authorization.k8s.io - clusterrolebindings.rbac.authorization.k8s.io - priorityclasses.scheduling.k8s.io includedNamespaceScopedResources: - deployments - serviceaccounts - secrets excludedNamespaceScopedResources: [] --- apiVersion: velero.io/v1 kind: Restore metadata: name: acm-klusterlet namespace: openshift-adp labels: velero.io/storage-location: default annotations: lca.openshift.io/apply-wave: "1" spec: backupName: acm-klusterlet- 1
multiclusterHubCR に.spec.imagePullSecretが定義されておらず、ハブクラスターのopen-cluster-management-agentnamespace にシークレットが存在しない場合は、v1/secrets/open-cluster-management-agent/open-cluster-management-image-pull-credentialsを削除します。
LVM Storage を介してクラスター上に永続ボリュームを作成した場合は、LVM Storage アーティファクトに次の YAML ファイルを追加します。
LVM Storage 用の PlatformBackupRestoreLvms.yaml
apiVersion: velero.io/v1 kind: Backup metadata: labels: velero.io/storage-location: default name: lvmcluster namespace: openshift-adp spec: includedNamespaces: - openshift-storage includedNamespaceScopedResources: - lvmclusters - lvmvolumegroups - lvmvolumegroupnodestatuses --- apiVersion: velero.io/v1 kind: Restore metadata: name: lvmcluster namespace: openshift-adp labels: velero.io/storage-location: default annotations: lca.openshift.io/apply-wave: "2"1 spec: backupName: lvmcluster- 1
lca.openshift.io/apply-waveの値は、アプリケーションのRestoreCR で指定された値よりも低くする必要があります。
アップグレード後にアプリケーションを復元する必要がある場合は、
openshift-adpnamespace にアプリケーションの OADPBackupCR およびRestoreCR を作成します。openshift-adpnamespace にクラスタースコープのアプリケーションアーティファクト用の OADP CR を作成します。LSO および LVM Storage のクラスタースコープアプリケーションアーティファクトの OADP CR の例
apiVersion: velero.io/v1 kind: Backup metadata: annotations: lca.openshift.io/apply-label: "apiextensions.k8s.io/v1/customresourcedefinitions/test.example.com,security.openshift.io/v1/securitycontextconstraints/test,rbac.authorization.k8s.io/v1/clusterroles/test-role,rbac.authorization.k8s.io/v1/clusterrolebindings/system:openshift:scc:test"1 name: backup-app-cluster-resources labels: velero.io/storage-location: default namespace: openshift-adp spec: includedClusterScopedResources: - customresourcedefinitions - securitycontextconstraints - clusterrolebindings - clusterroles excludedClusterScopedResources: - Namespace --- apiVersion: velero.io/v1 kind: Restore metadata: name: test-app-cluster-resources namespace: openshift-adp labels: velero.io/storage-location: default annotations: lca.openshift.io/apply-wave: "3"2 spec: backupName: backup-app-cluster-resourcesnamespace スコープのアプリケーションアーティファクト用の OADP CR を作成します。
LSO が使用される場合の OADP CR の namespace スコープのアプリケーションアーティファクトの例
apiVersion: velero.io/v1 kind: Backup metadata: labels: velero.io/storage-location: default name: backup-app namespace: openshift-adp spec: includedNamespaces: - test includedNamespaceScopedResources: - secrets - persistentvolumeclaims - deployments - statefulsets - configmaps - cronjobs - services - job - poddisruptionbudgets - <application_custom_resources>1 excludedClusterScopedResources: - persistentVolumes --- apiVersion: velero.io/v1 kind: Restore metadata: name: test-app namespace: openshift-adp labels: velero.io/storage-location: default annotations: lca.openshift.io/apply-wave: "4" spec: backupName: backup-app- 1
- アプリケーションのカスタムリソースを定義します。
LVM Storage が使用されている場合の OADP CR namespace スコープのアプリケーションアーティファクトの例
apiVersion: velero.io/v1 kind: Backup metadata: labels: velero.io/storage-location: default name: backup-app namespace: openshift-adp spec: includedNamespaces: - test includedNamespaceScopedResources: - secrets - persistentvolumeclaims - deployments - statefulsets - configmaps - cronjobs - services - job - poddisruptionbudgets - <application_custom_resources>1 includedClusterScopedResources: - persistentVolumes2 - logicalvolumes.topolvm.io3 - volumesnapshotcontents4 --- apiVersion: velero.io/v1 kind: Restore metadata: name: test-app namespace: openshift-adp labels: velero.io/storage-location: default annotations: lca.openshift.io/apply-wave: "4" spec: backupName: backup-app restorePVs: true restoreStatus: includedResources: - logicalvolumes5 重要アプリケーションの同じバージョンが、OpenShift Container Platform の現在のリリースとターゲットリリースの両方で機能する必要があります。
次のコマンドを実行して、OADP CR の
ConfigMapオブジェクトを作成します。$ oc create configmap oadp-cm-example --from-file=example-oadp-resources.yaml=<path_to_oadp_crs> -n openshift-adp次のコマンドを実行して、
ImageBasedUpgradeCR にパッチを適用します。$ oc patch imagebasedupgrades.lca.openshift.io upgrade \ -p='{"spec": {"oadpContent": [{"name": "oadp-cm-example", "namespace": "openshift-adp"}]}}' \ --type=merge -n openshift-lifecycle-agent