From 15f316b36bd3f94aa92a9d13156b50daf445d8d4 Mon Sep 17 00:00:00 2001 From: joy717 Date: Fri, 15 Apr 2022 14:36:44 +0800 Subject: [PATCH] fix VolumeExpansion not work --- .../helm/seaweedfs-csi-driver/templates/rbac.yml | 6 ++++++ .../templates/statefulset.yml | 16 ++++++++++++++++ .../templates/storageclass.yml | 1 + deploy/helm/seaweedfs-csi-driver/values.yaml | 4 ++++ pkg/driver/controllerserver.go | 4 ++-- pkg/driver/nodeserver.go | 7 ++++--- 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/deploy/helm/seaweedfs-csi-driver/templates/rbac.yml b/deploy/helm/seaweedfs-csi-driver/templates/rbac.yml index fced728..f373717 100644 --- a/deploy/helm/seaweedfs-csi-driver/templates/rbac.yml +++ b/deploy/helm/seaweedfs-csi-driver/templates/rbac.yml @@ -13,6 +13,9 @@ rules: - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update"] + - apiGroups: [ "" ] + resources: [ "persistentvolumeclaims/status" ] + verbs: [ "get", "list", "watch", "update", "patch" ] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] @@ -25,6 +28,9 @@ rules: - apiGroups: ["snapshot.storage.k8s.io"] resources: ["volumesnapshotcontents"] verbs: ["get", "list"] + - apiGroups: [ "" ] + resources: [ "pods" ] + verbs: [ "get", "list", "watch" ] --- kind: ClusterRoleBinding diff --git a/deploy/helm/seaweedfs-csi-driver/templates/statefulset.yml b/deploy/helm/seaweedfs-csi-driver/templates/statefulset.yml index 0b985e3..d28b719 100644 --- a/deploy/helm/seaweedfs-csi-driver/templates/statefulset.yml +++ b/deploy/helm/seaweedfs-csi-driver/templates/statefulset.yml @@ -49,6 +49,22 @@ spec: volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ + # resizer + - name: csi-resizer + image: {{ .Values.csiResizer.image }} + args: + - "--v=5" + - "--csi-address=$(ADDRESS)" + - "--leader-election=false" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: {{ .Values.imagePullPolicy }} + resources: + {{ toYaml .Values.csiAttacher.resources | nindent 12 }} + volumeMounts: + - name: socket-dir + mountPath: /var/lib/csi/sockets/pluginproxy/ # SeaweedFs Plugin - name: seaweedfs-csi-plugin image: {{.Values.seaweedfsCsiPlugin.image}} diff --git a/deploy/helm/seaweedfs-csi-driver/templates/storageclass.yml b/deploy/helm/seaweedfs-csi-driver/templates/storageclass.yml index c1f8c99..87ac757 100644 --- a/deploy/helm/seaweedfs-csi-driver/templates/storageclass.yml +++ b/deploy/helm/seaweedfs-csi-driver/templates/storageclass.yml @@ -8,4 +8,5 @@ metadata: storageclass.kubernetes.io/is-default-class: "true" {{- end }} provisioner: {{ .Values.driverName }} +allowVolumeExpansion: true {{- end }} diff --git a/deploy/helm/seaweedfs-csi-driver/values.yaml b/deploy/helm/seaweedfs-csi-driver/values.yaml index adc1c2e..77ad46e 100644 --- a/deploy/helm/seaweedfs-csi-driver/values.yaml +++ b/deploy/helm/seaweedfs-csi-driver/values.yaml @@ -19,6 +19,10 @@ csiAttacher: image: k8s.gcr.io/sig-storage/csi-attacher:v3.4.0 resources: {} +csiResizer: + image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0 + resources: {} + csiNodeDriverRegistrar: image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0 resources: {} diff --git a/pkg/driver/controllerserver.go b/pkg/driver/controllerserver.go index 535759d..b311732 100644 --- a/pkg/driver/controllerserver.go +++ b/pkg/driver/controllerserver.go @@ -187,11 +187,11 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi client := mount_pb.NewSeaweedMountClient(clientConn) _, err = client.Configure(context.Background(), &mount_pb.ConfigureRequest{ - CollectionCapacity: req.CapacityRange.LimitBytes, + CollectionCapacity: req.CapacityRange.RequiredBytes, }) return &csi.ControllerExpandVolumeResponse{ - CapacityBytes: req.CapacityRange.LimitBytes, + CapacityBytes: req.CapacityRange.RequiredBytes, }, err } diff --git a/pkg/driver/nodeserver.go b/pkg/driver/nodeserver.go index 1f3ce20..6c6fa19 100644 --- a/pkg/driver/nodeserver.go +++ b/pkg/driver/nodeserver.go @@ -136,7 +136,8 @@ func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC Type: &csi.NodeServiceCapability_Rpc{ Rpc: &csi.NodeServiceCapability_RPC{ // Type: csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME, - Type: csi.NodeServiceCapability_RPC_UNKNOWN, + //Type: csi.NodeServiceCapability_RPC_UNKNOWN, + Type: csi.NodeServiceCapability_RPC_EXPAND_VOLUME, }, }, }, @@ -181,11 +182,11 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV client := mount_pb.NewSeaweedMountClient(clientConn) _, err = client.Configure(context.Background(), &mount_pb.ConfigureRequest{ - CollectionCapacity: req.CapacityRange.LimitBytes, + CollectionCapacity: req.CapacityRange.RequiredBytes, }) return &csi.NodeExpandVolumeResponse{ - CapacityBytes: req.CapacityRange.LimitBytes, + CapacityBytes: req.CapacityRange.RequiredBytes, }, err }