展开卷
Trident使Kubnetes用户能够在创建卷后对其进行扩展。查找有关扩展 iSCSI 和 NFS 卷所需配置的信息。
展开 iSCSI 卷
您可以使用 CSI 配置程序扩展 iSCSI 永久性卷( PV )。
iSCSI 卷扩展受 ontap-san , ontap-san-economy , solidfire-san 驱动程序支持,需要 Kubernetes 1.16 及更高版本。
|
第 1 步:配置 StorageClass 以支持卷扩展
编辑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 ,请对其进行编辑,使其包含 allowVolumeExpansion
参数。
第 2 步:使用您创建的 StorageClass 创建 PVC
编辑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会创建一个永久性卷(PV)并将其与此永久性卷请求(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会扩展存储后端的卷。将 PVC 绑定到 Pod 后, Trident 会重新扫描设备并调整文件系统大小。然后, Kubernetes 会在扩展操作成功完成后更新 PVC 大小。
在此示例中,创建了一个使用 san-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
要将已创建的 PV 从 1Gi 调整为 2Gi ,请编辑 PVC 定义并将 sPec.resources.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卷的大小来验证扩展是否正常:
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 卷
Trident支持对、 ontap-nas-economy
、 ontap-nas-flexgroup
、 gcp-cvs`和 `azure-netapp-files`后端配置的NFS PV进行卷扩展 `ontap-nas
。
第 1 步:配置 StorageClass 以支持卷扩展
要调整 NFS PV 的大小,管理员首先需要将 allowVolumeExpansion
字段设置为 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
如果您已创建没有此选项的存储类,则只需使用 kubectl edit storageclass
编辑现有存储类即可进行卷扩展。
第 2 步:使用您创建的 StorageClass 创建 PVC
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
到1 GiB:
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卷的大小来验证调整大小是否正常:
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 | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+