展开卷
通过 Astra Trident , Kubernetes 用户可以在创建卷后对其进行扩展。查找有关扩展 iSCSI 和 NFS 卷所需配置的信息。
展开 iSCSI 卷
您可以使用 CSI 配置程序扩展 iSCSI 永久性卷( PV )。
|
支持iSCSI卷扩展 ontap-san , ontap-san-economy , solidfire-san 驱动程序并需要Kubernetes 1.16及更高版本。
|
扩展 iSCSI PV 包括以下步骤:
-
编辑StorageClass定义以设置
allowVolumeExpansion
字段设置为true
。 -
编辑PVC定义并更新
spec.resources.requests.storage
以反映新需要的大小、该大小必须大于原始大小。 -
要调整 PV 大小,必须将 PV 连接到 Pod 。调整 iSCSI PV 大小时,有两种情况:
-
如果 PV 连接到 Pod ,则 Astra Trident 会扩展存储后端的卷,重新扫描设备并调整文件系统大小。
-
尝试调整未连接 PV 的大小时, Astra Trident 会扩展存储后端的卷。将 PVC 绑定到 Pod 后, Trident 会重新扫描设备并调整文件系统大小。然后, Kubernetes 会在扩展操作成功完成后更新 PVC 大小。
-
以下示例显示了扩展 iSCSI PV 的工作原理。
第 1 步:配置 StorageClass 以支持卷扩展
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
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
在此示例中、创建了一个使用的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支持对上配置的NFS PV进行卷扩展 ontap-nas
, ontap-nas-economy
, ontap-nas-flexgroup
, gcp-cvs
,和 azure-netapp-files
后端。
第 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
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
到1 GB:
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 | +------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+