Using Block Storage storage classes
Deploying Pods and PVCs Using Storage Classes
You can deploy a pod and PVC that use bs-ssd by creating manifest files (for example,
bs-pod.yaml
and
bs-pvc.yaml
).
- The manifest file below is an example. * Modify key fields such as Image to match your environment.
To create a pod and PVC using the bs-ssd storage class, follow these steps.
Create the PVC manifest file
bs-pvc.yaml
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-ssd
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssd
volumeMode: Filesystem
resources:
requests:
storage: 8Gikind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-ssd
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssd
volumeMode: Filesystem
resources:
requests:
storage: 8GiCreate the pod manifest file
bs-pod.yaml
.
kind: Pod
apiVersion: v1
metadata:
name: pod-bs-ssd
spec:
containers:
- name: busybox
image: busybox:latest
command:
- sleep
- "3600"
volumeMounts:
- mountPath: "/data"
name: my-csi-volume
volumes:
- name: my-csi-volume
persistentVolumeClaim:
claimName: pvc-bs-ssdkind: Pod
apiVersion: v1
metadata:
name: pod-bs-ssd
spec:
containers:
- name: busybox
image: busybox:latest
command:
- sleep
- "3600"
volumeMounts:
- mountPath: "/data"
name: my-csi-volume
volumes:
- name: my-csi-volume
persistentVolumeClaim:
claimName: pvc-bs-ssd- Deploy the PVC and pod manifests using the kubectl apply command.Color mode
kubectl apply -f bs-pvc.yaml -f bs-pod.yamlkubectl apply -f bs-pvc.yaml -f bs-pod.yamlCode block. Deploy the manifest using the kubectl apply command
kubectl get pod,pvc
Run the command to verify the deployment results.
# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
persistentvolumeclaim/pvc-bs-ssd Bound pvc-5a085a06-164f-45e1-b4c6-d2bfa3b0012c 8Gi RWO bs-ssd
NAME READY STATUS RESTARTS AGE
pod/pod-bs-ssd 1/1 Running 0 75s# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
persistentvolumeclaim/pvc-bs-ssd Bound pvc-5a085a06-164f-45e1-b4c6-d2bfa3b0012c 8Gi RWO bs-ssd
NAME READY STATUS RESTARTS AGE
pod/pod-bs-ssd 1/1 Running 0 75sDeploy Pods and PVCs to a specific AZ (allowedTopologies)
Users can create a separate storage class that includes the allowedTopologies setting to ensure that pods and volumes are deployed to a specific AZ.
- We recommend creating additional storage classes by referring to the default bs-ssd storage class.
- We recommend using “topology.bs.csi.samsungsdscloud.com/zone” for matchLabelExpressions. * (For all node Label settings)
Create the storage class manifest file
bs-az-a-sc.yaml
.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssd-az-a
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD
allowedTopologies:
- matchLabelExpressions:
- key: topology.bs.csi.samsungsdscloud.com/zone
values:
- kr-west1-aapiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssd-az-a
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD
allowedTopologies:
- matchLabelExpressions:
- key: topology.bs.csi.samsungsdscloud.com/zone
values:
- kr-west1-a- Use the kubectl apply command to deploy the storage class, PVC, and pod manifests.Color mode
kubectl apply -f bs-az-a-sc.yaml -f bs-pvc.yaml -f bs-pod.yamlkubectl apply -f bs-az-a-sc.yaml -f bs-pvc.yaml -f bs-pod.yamlCode block. Deploy the manifest using the kubectl apply command
kubectl get pod,pvc
Use the command to verify the deployment results.
# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
pvc-bs-ssd Bound pvc-42365cee-724c-446a-af35-e54d9b16ad51 8Gi RWO bs-ssd-az-a
NAME READY STATUS RESTARTS AGE IP NODE
pod-bs-ssd 1/1 Running 0 46s 172.21.52.3 ske-aaa-lrwdj-vwww2# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
pvc-bs-ssd Bound pvc-42365cee-724c-446a-af35-e54d9b16ad51 8Gi RWO bs-ssd-az-a
NAME READY STATUS RESTARTS AGE IP NODE
pod-bs-ssd 1/1 Running 0 46s 172.21.52.3 ske-aaa-lrwdj-vwww2Deploying Pods and PVCs Using the ssd_provisioned Volume Type
Users can specify the max_iops and max_throughput of a volume created using the SSD_Provisioned volume type. You can specify max_iops and max_throughput in the PVC creation annotations (priority 1) or in the StorageClass parameters (priority 2). The following example demonstrates both configurations. (If all are configured, the pvc Annotation value is applied.)
- We recommend creating additional storage classes by referring to the default bs-ssd storage class.
- If max_iops and max_throughput are not reflected, the PVC creation request will fail.
Create the storage class manifest file
bs-ssdprovisioned-sc.yaml
.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssdprovisioned-sc
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD_Provisioned # Change volume type (SSD > SSD_Provisioned)
max_iops: "17000" # max_iops setting (5000-20000)
max_throughput: "250" # max_throughput setting (250-1000)apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssdprovisioned-sc
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD_Provisioned # Change volume type (SSD > SSD_Provisioned)
max_iops: "17000" # max_iops setting (5000-20000)
max_throughput: "250" # max_throughput setting (250-1000)Create the PVC manifest file
bs-ssdprovisioned-pvc.yaml
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-ssdprovisioned
annotations:
"bs.csi.samsungsdscloud.com/max-iops": "5000" # max_iops setting
"bs.csi.samsungsdscloud.com/max-throughput": "250" # max_throughput setting
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssdprovisioned-sc
volumeMode: Filesystem
resources:
requests:
storage: 8Gikind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-ssdprovisioned
annotations:
"bs.csi.samsungsdscloud.com/max-iops": "5000" # max_iops setting
"bs.csi.samsungsdscloud.com/max-throughput": "250" # max_throughput setting
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssdprovisioned-sc
volumeMode: Filesystem
resources:
requests:
storage: 8GiUse the kubectl apply command to deploy the storage class, PVC, and pod manifests.
Color modekubectl apply -f bs-ssdprovisioned-sc.yaml -f bs-ssdprovisioned-pvc.yaml -f bs-pod.yamlkubectl apply -f bs-ssdprovisioned-sc.yaml -f bs-ssdprovisioned-pvc.yaml -f bs-pod.yamlCode block. Deploy the manifest using the kubectl apply command You can check the max-iops and max-throughput values of the created volume in the console under Virtual Server > Block Storage.
The following describes the max-iops and max-throughput PVC annotations.
| Annotation | Required | Default | Scope | Description |
|---|---|---|---|---|
| bs.csi.samsungsdscloud.com/max-iops | Optional | - | 5000-20000 | IOPS value configured when creating the service |
| bs.csi.samsungsdscloud.com/max-throughput | Optional | - | 250-1000 | Throughput speed (MB/s) configured when creating the service |
Deploying a Replicated PVC Using volumeSnapshot
This guide explains how to clone and deploy a PVC using volumeSnapshot. The following example shows how to configure PVC replication using the default csi-bs-snapclass VolumeSnapshotClass.
- The original PVC and the replica PVC must be in the same Namespace.
- The related CRDs, volumesnapshotclass, snapshot controller, and so on are already deployed.
Creates a volumeSnapshot for the original PVC.
Color modeapiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: bs-snapshot-test spec: volumeSnapshotClassName: csi-bs-snapclass # The volumesnapshotclass to use source: persistentVolumeClaimName: pvc-bs-original-test # Original PVC to useapiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: bs-snapshot-test spec: volumeSnapshotClassName: csi-bs-snapclass # The volumesnapshotclass to use source: persistentVolumeClaimName: pvc-bs-original-test # Original PVC to useCode block. Example of writing volumeSnapshot.yaml Verify that volumeSnapshotContent was created successfully. 2. (Snapshot content is auto-generated)
Color mode$ kubectl get volumesnapshotcontent -owide NAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT VOLUMESNAPSHOTNAMESPACE AGE snapcontent-xxx true 111669149696 Delete bs.csi.samsungsdscloud.com csi-bs-snapclass bs-snapshot-test default 23s$ kubectl get volumesnapshotcontent -owide NAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT VOLUMESNAPSHOTNAMESPACE AGE snapcontent-xxx true 111669149696 Delete bs.csi.samsungsdscloud.com csi-bs-snapclass bs-snapshot-test default 23sCode block. Example of writing volumeSnapshot.yaml Create a replicated PVC using volumeSnapshot.
Color modekind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-bs-restored-test spec: accessModes: - ReadWriteOnce storageClassName: bs-ssd dataSource: name: bs-snapshot-test # Created volumeSnapshot kind: volumeSnapshot apiGroup: snapshot.storage.k8s.io volumeMode: Filesystem resources: requests: storage: 120Gikind: PersistentVolumeClaim apiVersion: v1 metadata: name: pvc-bs-restored-test spec: accessModes: - ReadWriteOnce storageClassName: bs-ssd dataSource: name: bs-snapshot-test # Created volumeSnapshot kind: volumeSnapshot apiGroup: snapshot.storage.k8s.io volumeMode: Filesystem resources: requests: storage: 120GiCode block. Example of writing volumeSnapshot.yaml
Deploying a PVC that uses the XFS file system
You can create a separate storage class that uses the XFS file system to format volumes provisioned with that storage class as XFS and mount them on the node.
- We recommend creating additional storage classes by referring to the default bs-ssd storage class.
- The default file system type for Block Storage CSI is ext4.
Create the storage class manifest file
bs-xfs-sc.yaml
.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssd-xfs
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD
csi.storage.k8s.io/fstype: xfsapiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: bs-ssd-xfs
provisioner: bs.csi.samsungsdscloud.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: SSD
csi.storage.k8s.io/fstype: xfsCreate the PVC manifest file
bs-xfs-pvc.yaml
.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-xfs
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssd-xfs
volumeMode: Filesystem
resources:
requests:
storage: 8Gikind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-bs-xfs
spec:
accessModes:
- ReadWriteOnce
storageClassName: bs-ssd-xfs
volumeMode: Filesystem
resources:
requests:
storage: 8Gi- Use the kubectl apply command to deploy the storage class, PVC, and pod manifests.Color mode
kubectl apply -f bs-xfs-sc.yaml -f bs-xfs-pvc.yamlkubectl apply -f bs-xfs-sc.yaml -f bs-xfs-pvc.yamlCode block. Deploy the manifest using the kubectl apply command
kubectl get pod,pvc
Run the command to verify the deployment results.
Additionally, you can access the node and run the
lsblk -f
command to check the file system type of the mounted volume.
# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
pvc-bs-xfs Bound pvc-9b1e7d34-5c82-4f6a-b3d0-1a7e48c2f905 8Gi RWO bs-ssd-xfs
NAME READY STATUS RESTARTS AGE IP NODE
pod-bs-ssd 1/1 Running 0 46s 172.21.52.3 ske-aaa-lrwdj-vwww2# kubectl get pod,pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
pvc-bs-xfs Bound pvc-9b1e7d34-5c82-4f6a-b3d0-1a7e48c2f905 8Gi RWO bs-ssd-xfs
NAME READY STATUS RESTARTS AGE IP NODE
pod-bs-ssd 1/1 Running 0 46s 172.21.52.3 ske-aaa-lrwdj-vwww2