メインコンテンツまでスキップ

Kubernetes 上で Persistent Volume を restore する

restore volume 機能を使うと、既存の snapshot から Persistent Volume(PV)のデータを restore できます。この処理は完全に Kubernetes ネイティブです。既存の snapshot を元に PVC を設定し、アプリケーションの PVC または volumeMount の設定を、新しく作成した PVC に向けます。背景については Kubernetes の volume PVC データソースに関するドキュメント を参照してください。

snapshot から volume を restore する​

snapshot をデータソースとして参照する PVC の YAML ファイルを設定し、apply します。

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: <new-pvc-name>
namespace: <namespace>
spec:
dataSource:
name: new-snapshot-test
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi

apply したら、この PVC を必要に応じてアプリケーションに設定します。