展开卷
通过 Astra Trident , Kubernetes 用户可以在创建卷后对其进行扩展。查找有关扩展 iSCSI 和 NFS 卷所需配置的信息。
展开 iSCSI 卷
您可以使用 CSI 配置程序扩展 iSCSI 永久性卷( PV )。
iSCSI卷扩展受、、 ontap-san-economy solidfire-san`驱动程序支持 `ontap-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
Astra 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 ,则 Astra Trident 会扩展存储后端的卷,重新扫描设备并调整文件系统大小。
-
尝试调整未连接 PV 的大小时, Astra Trident 会扩展存储后端的卷。将 PVC 绑定到 Pod 后, Trident 会重新扫描设备并调整文件系统大小。然后, Kubernetes 会在扩展操作成功完成后更新 PVC 大小。
在此示例中,创建了一个使用的POD san-pvc
。
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 和 Astra 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 卷
Astra Trident支持对、 ontap-nas-economy
、 ontap-nas-flexgroup
、 gcp-cvs`和 `azure-netapp-files`后端配置的NFS PV进行卷扩展 `ontap-nas
。
第 1 步:配置 StorageClass 以支持卷扩展
要调整NFS PV的大小,管理员首先需要通过将字段设置为来将存储类配置为 true`允许卷扩展 `allowVolumeExpansion
:
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
Astra Trident 应为此 PVC 创建一个 20 MiB 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 和 Astra 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 | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+