LoginSignup
0
1

Support for Kubernetes volume clones in OKE

Last updated at Posted at 2023-11-13

CSIボリュームプラグインでは現在、Kubernetes Volume Clone を使用して、新しい永続ボリューム( Block Volume )の提供をサポートしています。

  • CSI ボリュームプラグインのアップデート:
    Kubernetes のボリューム( PersistentVolume と紐づく Block Volume )クローンをサポート
  • ボリュームクローンの使用:
    Block Volume サービスによる Block Volume クローンを利用して、新しい永続ボリュームを提供
  • クローンの特徴:
    既存の永続 Block Volume の完全な複製を作成
    ソースとなる Block Volume のデータを含む新しい永続 Block Volume を独立して提供
  • 利用シナリオ:
    本番環境に影響を与えずに設定変更を迅速にテスト可能
    データの整合性を保ちながら新しい Block Volume への迅速なデータ移行を実現

01.png

ソースとなる Block Volume 環境

50GiB のブロックボリュームをプロビジョニングして、PersistetVolume と紐づけます。

マニフェスト:csi-mysourcepvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-source-pvc
spec:
  storageClassName: "oci-bv"
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
kubectl apply -f csi-mysourcepvc.yaml
persistentvolumeclaim/my-source-pvc created

作成した PersistentVolumeClaim を要求して、Nginx のボリュームマウント先とするサンプル Pod をデプロイします。

マニフェスト:my-source-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: source-pod
spec:
  containers:
    - name: source-nginx
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: sample-volume
  volumes:
  - name: sample-volume
    persistentVolumeClaim:
      claimName: my-source-pvc
kubectl apply -f my-source-pod.yaml
persistentvolumeclaim/my-source-pvc created
pod/source-pod created

Pod, PersistentVolumeClaim, PersistentVolume が Bound 状態にあることを確認します。

kubectl get pv,pvc,pod
NAME                                  READY   STATUS    RESTARTS   AGE
pod/source-pod                        1/1     Running   0          74s

NAME                                  STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/my-source-pvc   Bound    csi-7de707b5-f2cd-4b39-b608-418146cd3694   50Gi       RWO            oci-bv         97s

NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                   STORAGECLASS   REASON   AGE
persistentvolume/csi-7de707b5-f2cd-4b39-b608-418146cd3694   50Gi       RWO            Delete           Bound    default/my-source-pvc   oci-bv                  58s

クローンとして作成された Block Volume 環境

Ngix Pod のコンテナ内(/usr/share/nginx/html/)にテストファイル(hello.txt)を作成します。クローンされて、新たな Block Volume でもこのテストファイルがあることになります。

kubectl exec -it source-pod -- sh -c 'echo "Hello World!" > /usr/share/nginx/html/hello.txt'

テストファイルが作成されたことを確認します。

kubectl exec -it source-pod -- sh -c 'cat /usr/share/nginx/html/hello.txt'
Hello World!

同じ形式で新たに Nginx Pod, PersistentVolume, PersistentVolumeClaim をデプロイします。

dataSource で my-source-pvc を指定します。

マニフェスト:csi-myclonepvc.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-clone-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: "oci-bv"
  resources:
    requests:
      storage: 50Gi
  dataSource:
    kind: PersistentVolumeClaim
    name: my-source-pvc

新たに作成した PersistentVolumeClaim を要求して、Nginx のボリュームマウント先とするサンプル Pod をデプロイします。

マニフェスト:my-clone-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: clone-pod
spec:
  containers:
    - name: clone-nginx
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: sample-volume
  volumes:
  - name: sample-volume
    persistentVolumeClaim:
      claimName: my-clone-pvc
kubectl apply -f csi-myclonepvc.yaml
persistentvolumeclaim/my-clone-pvc created
kubectl apply -f my-clone-pod.yaml
pod/clone-pod created

新たに作成した Pod, PersistentVolumeClaim, PersistentVolume が Bound 状態にあることを確認します。(pod/clone-pod, persistentvolumeclaim/my-clone-pvc, persistentvolume/csi-b44b918a-0877-4544-b1ad-44cb9f403622)

kubectl get pv,pvc,pod
NAME                                  READY   STATUS    RESTARTS   AGE
pod/clone-pod                         1/1     Running   0          3m38s
pod/source-pod                        1/1     Running   0          14m

NAME                                  STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/my-clone-pvc    Bound    csi-b44b918a-0877-4544-b1ad-44cb9f403622   50Gi       RWO            oci-bv         4m9s
persistentvolumeclaim/my-source-pvc   Bound    csi-7de707b5-f2cd-4b39-b608-418146cd3694   50Gi       RWO            oci-bv         15m

NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                   STORAGECLASS   REASON   AGE
persistentvolume/csi-7de707b5-f2cd-4b39-b608-418146cd3694   50Gi       RWO            Delete           Bound    default/my-source-pvc   oci-bv                  14m
persistentvolume/csi-b44b918a-0877-4544-b1ad-44cb9f403622   50Gi       RWO            Delete           Bound    default/my-clone-pvc    oci-bv                  3m27s

テストファイル(hello.txt)があることを確認します。

kubectl exec -it clone-pod -- sh -c 'cat /usr/share/nginx/html/hello.txt'
Hello World!

以上です。

Official Documents

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1