Using Block Storage storage class
Deploy pod and pvc using storage class
Create a manifest file (example:
bs-pod.yaml
and
bs-pvc.yaml
) to deploy a pod and PVC that use bs-ssd.
- The manifest file below is an example. * Please adjust key fields, such as Image, to match the user’s 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
use 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 pod and pvc to a specific AZ (allowedTopologies)
The user can create a separate storage class that includes the allowedTopologies setting, enabling pods and volumes to be scheduled to a specific AZ.
- Based on the default deployed bs-ssd storage class, we recommend creating additional storage classes.
- It is recommended to use “topology.bs.csi.samsungsdscloud.com/zone” with matchLabelExpressions. * (Label not applied to all nodes)
Create the storageclass 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- Deploy the storageclass, pvc, and pod manifests using the kubectl apply command.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 manifest with the kubectl apply command
Check the deployment result using the
kubectl get pod,pvc
command.
# 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-vwww2Deploy pod and PVC 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. max_iops and max_throughput can be set in the created PVC annotation (first priority) or in the storage class parameters (second priority). The example below shows a case that reflects both settings. (If all are configured, the pvc Annotation value is applied.)
- Based on the default deployed bs-ssd storage class, we recommend creating additional storage classes.
- If max_iops and max_throughput are not applied, the PVC creation request will fail.
Create the storageclass 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)Write 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: 8GiDeploy the storageclass, pvc, and pod manifests using the kubectl apply command.
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 with the kubectl apply command. The max‑iops and max‑throughput values of the created volume can be viewed in the console under Virtual Server > Block Storage.
Below is an explanation of the max-iops and max-throughput PVC annotations.
| Annotation | required | default | range | Explanation |
|---|---|---|---|---|
| bs.csi.samsungsdscloud.com/max-iops | Optional | - | 5000-20000 | IOPS value set when creating the service |
| bs.csi.samsungscloud.com/max-throughput | Optional | - | 250-1000 | Throughput rate (MB/s) set when creating the service |
Deploy replicated PVC using volumeSnapshot
This is a guide for cloning and deploying pvc using volumeSnapshot. The example below shows a PVC replication configuration using the built-in csi-bs-snapclass VolumeSnapshotClass.
- The original PVC and the replica PVC must be located in the same Namespace.
- The related CRD, volumesnapshotclass, snapshot controller, etc., have already been deployed.
Create a volumeSnapshot that targets the original PVC.
Color modeapiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: bs-snapshot-test spec: volumeSnapshotClassName: csi-bs-snapclass # volumesnapshotclass to use source: persistentVolumeClaimName: pvc-bs-original-test # original PVCapiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: bs-snapshot-test spec: volumeSnapshotClassName: csi-bs-snapclass # volumesnapshotclass to use source: persistentVolumeClaimName: pvc-bs-original-test # original PVCCode block. Example of writing volumeSnapshot.yaml Verify that the volumeSnapshotContent was created correctly. 2. (snapshot content is automatically 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 cloned PVC using a 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