Skip to content

Latest commit

 

History

History
247 lines (209 loc) · 6.65 KB

user-guide.md

File metadata and controls

247 lines (209 loc) · 6.65 KB

User Guide

Set Storage Class

An example of Storage Class

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: csi-neonsan
provisioner: neonsan.csi.qingstor.com
parameters:
  fsType: "ext4"
  rep_count: "1"
  pool_name: "kube"
reclaimPolicy: Delete
allowVolumeExpansion: true

Parameters in Storage Class

fsType

Support ext3, ext4, xfs, default ext4.

rep_count

Number of disk replicas, default 1,maximum 3.

pool_name

Neonsan pool name,not empty

Other Parameters

Set Default Storage Class

Set the annotation .metadata.annotations.storageclass.beta.kubernetes.io/is-default-class value as true. See details in Kubernetes docs

Volume Expansion

Set the value of .allowVolumeExpansion as true. See details in Kubernetes docs

Volume Management

Volume management including dynamical provisioning/deleting volume, attaching/detaching volume. Please reference Example YAML Files.

Prerequisite

  • Kubernetes 1.14+
  • Neonsan CSI installed
  • Neonsan CSI StorageClass created

Create Storage Class

  • Create
$ kubectl create -f sc.yaml
  • Check
$ kubectl get sc
NAME            PROVISIONER              AGE
csi-neonsan neonsan.csi.qingstor.com   14m

Create PVC

  • Create
$ kubectl create -f pvc.yaml 
persistentvolumeclaim/pvc-test created
  • Check
$ kubectl get pvc pvc-test
NAME          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS    AGE
pvc-test      Bound    pvc-76429525-a930-11e9-9a6a-5254ef68c8c1   20Gi       RWO            csi-neonsan     25m

Mount Volume

  • Create Deployment
$ kubectl create -f deploy-nginx.yaml 
deployment.apps/nginx created
  • Check
$ kubectl exec -ti nginx-84474cf674-zfhbs /bin/bash
# cd /mnt
# ls
lost+found

Unmount Volume

  • Delete Deployment
$ kubectl delete deploy nginx
deployment.extensions "nginx" deleted

Delete PVC

  • Delete
$ kubectl delete pvc pvc-test
persistentvolumeclaim "pvc-test" deleted
  • Check
$ kubectl get pvc pvc-test
Error from server (NotFound): persistentvolumeclaims "pvc-example" not found

Volume Expansion

This plugin only supports offline volume expansion. The procedure of offline volume expansion is shown as follows.

  1. Ensure volume in unmounted status
  2. Edit the capacity of PVC
  3. Mount volume on workload Please reference Example YAML files.

Prerequisite

  • Kubernetes 1.14+ cluster
  • Add ExpandCSIVolumes=true in feature-gate
  • Set allowVolumeExpansion as true in StorageClass
  • Create a Pod mounting a volume

Unmount Volume

$ kubectl scale deploy nginx --replicas=0

Expand Volume

  • Change Volume capacity
$ kubectl patch pvc pvc-test -p '{"spec":{"resources":{"requests":{"storage": "40Gi"}}}}'
persistentvolumeclaim/pvc-test patched
  • Mount Volume
$ kubectl scale deploy nginx --replicas=1
  • Check PVC Capacity
$ kubectl get pvc pvc-test
NAME          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS    AGE
pvc-test   Bound    pvc-906f5760-a935-11e9-9a6a-5254ef68c8c1   40Gi       RWO            csi-qingcloud   6m7s
$ kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6c444c9b7f-d6n29   1/1     Running   0          3m38s

Check

$ kubectl exec -ti nginx-6c444c9b7f-d6n29 /bin/bash
root@nginx-6c444c9b7f-d6n29:/# df -ah
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/vdc         40G   49M   40G   1% /mnt
...

Volume Cloning

Cloning is defined as a duplicate of an existing PVC. Please reference Example YAML

Prerequisites

  • Kubernetes 1.15+
  • Enable VolumePVCDataSource=true feature gat
  • Neonsan CSI installed
  • Neonsan CSI StorageClass created
  • Source PVC created

Clone Volume

  • Check source PVC
$ kubectl get pvc pvc-test
NAME       STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-test   Bound    pvc-3bdbde24-7016-430e-b217-9eca185caca3   20Gi       RWO            csi-neonsan    3h16
  • Clone Volume
$ kubectl create -f pvc-clone.yaml
persistentvolumeclaim/pvc-clone created
  • Check
$ kubectl get pvc pvc-clone
NAME        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-clone   Bound    pvc-a75e3f7c-59af-43ef-82d3-300508871432   20Gi       RWO            csi-neonsan    7m4s

Snapshot Management

Snapshot management contains creating/deleting snapshot and restoring volume from snapshot. Please reference Example YAML files.

Prerequisites

  • Kubernetes 1.14+
  • Enable VolumeSnapshotDataSource=true feature gate at kube-apiserver and kube-controller-manager
  • Neonsan CSI v1.2.0 installed
  • Neonsan CSI StorageClass created
  • Source PVC created

Create Source PVC pvc-source

  • Create
$ kubectl create -f pvc-source.yaml
persistentvolumeclaim/pvc-source created
  • Check
$ kubectl get pvc pvc-source
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS    AGE
pvc-source   Bound    pvc-3bdbde24-7016-430e-b217-9eca185caca3   20Gi       RWO            csi-neonsan    4h25m

Create Volume Snapshot

Create VolumeSnapshotClass

$ kubectl create -f snapshot-class.yaml
volumesnapshotclass.snapshot.storage.k8s.io/csi-neonsan created
 
$ kubectl get volumesnapshotclass
NAME            AGE
csi-neonsdan    16s

Create VolumeSnapshot

$ kubectl create -f snapshot.yaml 
volumesnapshot.snapshot.storage.k8s.io/snap-1 created

$ kubectl get volumesnapshot
NAME     AGE
snap-1   91s

Restore from VolumeSnapshot

create PVC pvc-snap from snapshot

$ kubectl create -f pvc-snapshot.yaml 
persistentvolumeclaim/pvc-snap created
$ kubectl get pvc pvc-snap
NAME       STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
pvc-snap   Bound    pvc-a56f6ebe-b37b-40d7-bfb7-aafbecb6672b   20Gi       RWO            csi-neonsan    59m

Delete VolumeSnapshot

$ kubectl delete volumesnapshot snap-1
volumesnapshot.snapshot.storage.k8s.io "snap-1" deleted