展開Volume
Trident 可讓 Kubernetes 使用者在建立磁碟區之後擴充其容量。尋找擴充iSCSI和NFS磁碟區所需組態的相關資訊。
展開iSCSI Volume
您可以使用「SCSI資源配置程式」來擴充iSCSI持續磁碟區(PV)。
iSCSI磁碟區擴充支援「ontap-san」、「ONTAP-san經濟」、「Poolidfire-san」等驅動程式、需要Kubernetes 1.16及更新版本。 |
步驟1:設定StorageClass以支援Volume擴充
編輯 StorageClass 定義以設定 allowVolumeExpansion
欄位至 true
。
cat storageclass-ontapsan.yaml --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: ontap-san provisioner: csi.trident.netapp.io parameters: backendType: "ontap-san" allowVolumeExpansion: True
對於已存在的StorageClass、請編輯此類以包含「owalumVolume Expansion」參數。
步驟2:使用您建立的StorageClass建立一個永久虛擬儲存設備
編輯 PVC 定義並更新 spec.resources.requests.storage
以反映新的所需大小、此大小必須大於原始大小。
cat pvc-ontapsan.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: san-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi storageClassName: ontap-san
Trident 會建立持續 Volume ( PV )、並將其與此持續 Volume Claim ( PVC )相關聯。
kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE san-pvc Bound pvc-8a814d62-bd58-4253-b0d1-82f2885db671 1Gi RWO ontap-san 8s kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-8a814d62-bd58-4253-b0d1-82f2885db671 1Gi RWO Delete Bound default/san-pvc ontap-san 10s
步驟3:定義一個連接至PVc的Pod
將 PV 附加至 Pod 、以便調整大小。調整iSCSI PV的大小有兩種情況:
-
如果 PV 附加至 Pod 、 Trident 會在儲存後端擴充磁碟區、重新掃描裝置、並調整檔案系統的大小。
-
當嘗試調整未附加 PV 的大小時、 Trident 會在儲存後端擴充磁碟區。在將永久虛擬磁碟綁定至Pod之後、Trident會重新掃描裝置並重新調整檔案系統的大小。然後、Kubernetes會在擴充作業成功完成後、更新PVc大小。
在此範例中、會建立使用「shan -PVc」的Pod。
kubectl get pod NAME READY STATUS RESTARTS AGE ubuntu-pod 1/1 Running 0 65s kubectl describe pvc san-pvc Name: san-pvc Namespace: default StorageClass: ontap-san Status: Bound Volume: pvc-8a814d62-bd58-4253-b0d1-82f2885db671 Labels: <none> Annotations: pv.kubernetes.io/bind-completed: yes pv.kubernetes.io/bound-by-controller: yes volume.beta.kubernetes.io/storage-provisioner: csi.trident.netapp.io Finalizers: [kubernetes.io/pvc-protection] Capacity: 1Gi Access Modes: RWO VolumeMode: Filesystem Mounted By: ubuntu-pod
步驟4:展開PV
若要調整從1Gi建立至2Gi的PV大小、請編輯PVc定義、並將「sec.resumes.requests.storage」更新為2Gi。
kubectl edit pvc san-pvc # Please edit the object below. Lines beginning with a '#' will be ignored, # and an empty file will abort the edit. If an error occurs while saving this file will be # reopened with the relevant failures. # apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: pv.kubernetes.io/bind-completed: "yes" pv.kubernetes.io/bound-by-controller: "yes" volume.beta.kubernetes.io/storage-provisioner: csi.trident.netapp.io creationTimestamp: "2019-10-10T17:32:29Z" finalizers: - kubernetes.io/pvc-protection name: san-pvc namespace: default resourceVersion: "16609" selfLink: /api/v1/namespaces/default/persistentvolumeclaims/san-pvc uid: 8a814d62-bd58-4253-b0d1-82f2885db671 spec: accessModes: - ReadWriteOnce resources: requests: storage: 2Gi ...
步驟5:驗證擴充
您可以檢查 PVC 、 PV 和 Trident Volume 的大小、以驗證擴充是否正常運作:
kubectl get pvc san-pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE san-pvc Bound pvc-8a814d62-bd58-4253-b0d1-82f2885db671 2Gi RWO ontap-san 11m kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-8a814d62-bd58-4253-b0d1-82f2885db671 2Gi RWO Delete Bound default/san-pvc ontap-san 12m tridentctl get volumes -n trident +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+ | NAME | SIZE | STORAGE CLASS | PROTOCOL | BACKEND UUID | STATE | MANAGED | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+ | pvc-8a814d62-bd58-4253-b0d1-82f2885db671 | 2.0 GiB | ontap-san | block | a9b7bfff-0505-4e31-b6c5-59f492e02d33 | online | true | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+
展開NFS Volume
Trident 支援 NFS PV 的 Volume 擴充、部署於 ontap-nas
、 ontap-nas-economy
、 ontap-nas-flexgroup
`gcp-cvs`和 `azure-netapp-files`後端。
步驟1:設定StorageClass以支援Volume擴充
若要調整NFS PV的大小、管理員必須先將「ow淺Volume Expansion」欄位設定為「true」、以設定儲存類別以允許磁碟區擴充:
cat storageclass-ontapnas.yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: ontapnas provisioner: csi.trident.netapp.io parameters: backendType: ontap-nas allowVolumeExpansion: true
如果您已經建立了沒有此選項的儲存類別、只要使用「kubecl Edit storageclass'」來編輯現有的儲存類別、即可進行磁碟區擴充。
步驟2:使用您建立的StorageClass建立一個永久虛擬儲存設備
cat pvc-ontapnas.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: ontapnas20mb spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Mi storageClassName: ontapnas
Trident 應為此 PVC 建立 20MiB NFS PV :
kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE ontapnas20mb Bound pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 20Mi RWO ontapnas 9s kubectl get pv pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 20Mi RWO Delete Bound default/ontapnas20mb ontapnas 2m42s
步驟3:展開PV
若要將新建立的20MiB PV調整至1GiB、請編輯該PVC並設定組合 spec.resources.requests.storage
至 1GiB :
kubectl edit pvc ontapnas20mb # Please edit the object below. Lines beginning with a '#' will be ignored, # and an empty file will abort the edit. If an error occurs while saving this file will be # reopened with the relevant failures. # apiVersion: v1 kind: PersistentVolumeClaim metadata: annotations: pv.kubernetes.io/bind-completed: "yes" pv.kubernetes.io/bound-by-controller: "yes" volume.beta.kubernetes.io/storage-provisioner: csi.trident.netapp.io creationTimestamp: 2018-08-21T18:26:44Z finalizers: - kubernetes.io/pvc-protection name: ontapnas20mb namespace: default resourceVersion: "1958015" selfLink: /api/v1/namespaces/default/persistentvolumeclaims/ontapnas20mb uid: c1bd7fa5-a56f-11e8-b8d7-fa163e59eaab spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi ...
步驟4:驗證擴充
您可以檢查 PVC 、 PV 和 Trident Volume 的大小、以驗證調整大小是否正常運作:
kubectl get pvc ontapnas20mb NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE ontapnas20mb Bound pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 1Gi RWO ontapnas 4m44s kubectl get pv pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 1Gi RWO Delete Bound default/ontapnas20mb ontapnas 5m35s tridentctl get volume pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 -n trident +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+ | NAME | SIZE | STORAGE CLASS | PROTOCOL | BACKEND UUID | STATE | MANAGED | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+ | pvc-08f3d561-b199-11e9-8d9f-5254004dfdb7 | 1.0 GiB | ontapnas | file | c5a6f6a4-b052-423b-80d4-8fb491a14a22 | online | true | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+