Trident PROTECTを使用したOpenShift Container Platformのコンテナアプリケーションのデータ保護
リファレンスドキュメントのこのセクションでは、Trident保護を使用してコンテナアプリケーションのスナップショットとバックアップを作成する方法について詳しく説明します。NetApp Trident Protectは、NetApp ONTAPストレージシステムとNetApp Trident CSIストレージプロビジョニングツールを基盤とするステートフルなKubernetesアプリケーションの機能と可用性を強化する、高度なアプリケーションデータ管理機能を提供します。Trident保護では、アプリケーションのSnapshotとバックアップが作成されます。つまり、永続ボリューム内のアプリケーションデータのSnapshotとバックアップが作成されるだけでなく、アプリケーションメタデータのSnapshotとバックアップも作成されます。Trident保護で作成されたSnapshotとバックアップは、次のいずれかのオブジェクトストレージに格納して、あとでリストアできます。
-
AWS S3
-
Azure BLOBストレージ
-
Google Cloud Storage
-
ONTAP S3
-
StorageGRID
-
その他のS3互換ストレージ
Trident保護では、KubernetesモデルのRole-Based Access Control(RBAC;ロールベースアクセス制御)が使用されます。デフォルトでは、Trident protectは、Trident protectと呼ばれる単一のシステムネームスペースとそれに関連付けられたデフォルトのサービスアカウントを提供します。多数のユーザがいる組織や、特定のセキュリティニーズがある組織では、Trident保護のRBAC機能を使用して、リソースやネームスペースへのアクセスをより細かく制御できます。
Trident保護のRBACの詳細については、を参照してください。"Trident保護に関するドキュメント"
|
クラスタ管理者は、デフォルトのTrident保護ネームスペース内のリソースにアクセスできます。また、他のすべてのネームスペース内のリソースにもアクセスできます。SnapshotやバックアップCRSなどのアプリケーションデータ管理カスタムリソース(CRS)をTrident保護ネームスペースに作成することはできません。ベストプラクティスとして、アプリケーションネームスペースにCRSを作成する必要があります。 |
Trident protectは、ドキュメントに記載されている手順に従ってインストールでき"ここをクリック"ます。このセクションでは、コンテナアプリケーションのデータ保護と、Trident protectを使用したアプリケーションのリストアのワークフローを示します。1.スナップショットの作成(スケジュールに応じてオンデマンドで) 2.Snapshotからのリストア(同じ別のネームスペースへのリストア)3.バックアップの作成4.バックアップからリストア
前提条件
アプリケーションのSnapshotとバックアップを作成する前に、Trident保護でオブジェクトストレージを設定してSnapshotとバックアップを格納する必要があります。これにはバケットCRを使用します。バケットCRを作成して設定できるのは管理者だけです。バケットCRは、Trident保護ではAppVaultと呼ばれています。AppVaultオブジェクトは、ストレージバケットの宣言型Kubernetesワークフロー表現です。AppVault CRには、バックアップ、Snapshot、リストア処理、SnapMirrorレプリケーションなど、保護処理でバケットを使用するために必要な設定が含まれています。
この例では、ONTAP S3をオブジェクトストレージとして使用しています。ONTAP S3用のAppVault CRを作成するためのワークフローは次のとおりです。1.ONTAPクラスタのSVMにS3オブジェクトストアサーバを作成します。2.オブジェクトストアサーバにバケットを作成します。3.SVMにS3ユーザを作成します。アクセスキーとシークレットキーは安全な場所に保管してください。4.OpenShiftで、ONTAP S3クレデンシャルを格納するシークレットを作成します。5.ONTAP S3用のAppVaultオブジェクトの作成
-
ONTAP S3用のTrident保護AppVaultの構成**
-
ONTAP S3をAppVaultとしてTrident保護を設定するためのサンプルYAMLファイル***
-
# alias tp='tridentctl-protect'
appvault-secret.yaml
apiVersion: v1
stringData:
accessKeyID: "<access key id created for a user to access ONTAP S3 bucket>"
secretAccessKey: "corresponding Secret Access Key"
#data:
# base 64 encoded values
# accessKeyID: <base64 access key id created for a user to access ONTAP S3 bucket>
# secretAccessKey: <base 64 Secret Access Key>
kind: Secret
metadata:
name: appvault-secret
namespace: trident-protect
type: Opaque
appvault.yaml
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: ontap-s3-appvault
namespace: trident-protect
spec:
providerConfig:
azure:
accountName: ""
bucketName: ""
endpoint: ""
gcp:
bucketName: ""
projectID: ""
s3:
bucketName: <bucket-name for storing the snapshots and backups>
endpoint: <endpoint IP for S3>
secure: "false"
skipCertValidation: "true"
providerCredentials:
accessKeyID:
valueFromSecret:
key: accessKeyID
name: appvault-secret
secretAccessKey:
valueFromSecret:
key: secretAccessKey
name: appvault-secret
providerType: OntapS3
# oc create -f appvault-secret.yaml -n trident-protect
# oc create -f appvault.yaml -n trident-protect
-
PostgreSQLアプリケーションをインストールするためのサンプルYAMLファイル***
postgres.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:14
env:
- name: POSTGRES_USER
#value: "myuser"
value: "admin"
- name: POSTGRES_PASSWORD
#value: "mypassword"
value: "adminpass"
- name: POSTGRES_DB
value: "mydb"
- name: PGDATA
value: "/var/lib/postgresql/data/pgdata"
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
type: ClusterIP
Now create the Trident protect application CR for the postgres app. Include the objects in the namespace postgres and create it in the postgres namespace.
# tp create app postgres-app --namespaces postgres -n postgres
Snapshotの作成
オンデマンドスナップショットの作成
# tp create snapshot postgres-snap1 --app postgres-app --appvault ontap-s3-appvault -n postgres
Snapshot "postgres-snap1" created.
スケジュールの作成次のコマンドを使用すると、毎日15時33分にスナップショットが作成され、2つのスナップショットとバックアップが保持されます。
# tp create schedule schedule1 --app postgres-app --appvault ontap-s3-appvault --backup-retention 2 --snapshot-retention 2 --granularity Daily --hour 15 --minute 33 --data-mover Restic -n postgres
Schedule "schedule1" created.
-
YAMLを使用したスケジュールの作成**
# tp create schedule schedule2 --app postgres-app --appvault ontap-s3-appvault --backup-retention 2 --snapshot-retention 2 --granularity Daily --hour 15 --minute 33 --data-mover Restic -n postgres --dry-run > hourly-snapshotschedule.yaml
cat hourly-snapshotschedule.yaml
apiVersion: protect.trident.netapp.io/v1
kind: Schedule
metadata:
creationTimestamp: null
name: schedule2
namespace: postgres
spec:
appVaultRef: ontap-s3-appvault
applicationRef: postgres-app
backupRetention: "2"
dataMover: Restic
dayOfMonth: ""
dayOfWeek: ""
enabled: true
granularity: Hourly
#hour: "15"
minute: "33"
recurrenceRule: ""
snapshotRetention: "2"
status: {}
このスケジュールで作成されたSnapshotを表示できます。
ボリュームSnapshotも作成されます。
アプリケーションを削除してアプリケーションの損失をシミュレートする
# oc delete deployment/postgres -n postgres
# oc get pod,pvc -n postgres
No resources found in postgres namespace.
Snapshotから同じネームスペースへのリストア
# tp create sir postgres-sir --snapshot postgres/hourly-3f1ee-20250214183300 -n postgres
SnapshotInplaceRestore "postgres-sir" created.
アプリケーションとそのPVCが同じネームスペースにリストアされます。
Snapshotから別のネームスペースへのリストア
# tp create snapshotrestore postgres-restore --snapshot postgres/hourly-3f1ee-20250214183300 --namespace-mapping postgres:postgres-restore -n postgres-restore
SnapshotRestore "postgres-restore" created.
アプリケーションが新しいネームスペースにリストアされたことがわかります。
バックアップを作成します
オンデマンドバックアップの作成
# tp create backup postgres-backup1 --app postgres-app --appvault ontap-s3-appvault -n postgres
Backup "postgres-backup1" created.
バックアップスケジュールの作成
上記のリストに含まれる日単位および時間単位のバックアップは、以前に設定したスケジュールに基づいて作成されます。
# tp create schedule schedule1 --app postgres-app --appvault ontap-s3-appvault --backup-retention 2 --snapshot-retention 2 --granularity Daily --hour 15 --minute 33 --data-mover Restic -n postgres
Schedule "schedule1" created.
バックアップからリストア
データ損失をシミュレートするには、アプリケーションとPVCを削除します。
同じネームスペースにリストア#tp create bir postgres-bir --backup postgres/hourly-3f1ee-20250224023300 -n postgres BackupInplaceRestore "postgres-bir"が作成されました。
アプリケーションとPVCが同じネームスペースにリストアされます。
別の名前空間に復元新しい名前空間を作成します。バックアップから新しいネームスペースにリストアします。
アプリケーションの移行
アプリケーションを別のクラスタにクローニングまたは移行する(クラスタ間クローニングを実行する)には、ソースクラスタでバックアップを作成し、そのバックアップを別のクラスタにリストアします。デスティネーションクラスタにTrident protectがインストールされていることを確認します。
ソースクラスタで、次の図に示す手順を実行します。
ソースクラスタから、コンテキストをデスティネーションクラスタに切り替えます。次に、AppVaultがデスティネーションクラスタコンテキストからアクセス可能であることを確認し、AppVaultのコンテンツをデスティネーションクラスタから取得します。
リストからバックアップパスを指定し、以下のコマンドのようにBackupRestore CRオブジェクトを作成します。
# tp create backuprestore backup-restore-cluster2 --namespace-mapping postgres:postgres --appvault ontap-s3-appvault --path postgres-app_4d798ed5-cfa8-49ff-a5b6-c5e2d89aeb89/backups/postgres-backup-cluster1_ec0ed3f3-5500-4e72-afa8-117a04a0b1c3 -n postgres
BackupRestore "backup-restore-cluster2" created.
これで、アプリケーションポッドとPVCがデスティネーションクラスタに作成されたことがわかります。