Skip to content

Commit

Permalink
Add support for expanding volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjoemccormick committed Jun 10, 2024
1 parent 8792f2a commit 4f37cf1
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
21 changes: 21 additions & 0 deletions deploy/k8s/bases/csi-beegfs-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ spec:
requests:
cpu: 80m
memory: 24Mi
- name: csi-resizer
image: registry.k8s.io/sig-storage/csi-resizer:v1.11.1
args:
- "--csi-address=/csi/csi.sock"
- -v=$(LOG_LEVEL)
securityContext:
# On SELinux enabled systems, a non-privileged sidecar container cannot access the unix domain socket
# created by the privileged driver container.
privileged: true
env:
- name: LOG_LEVEL
value: "3"
volumeMounts:
- mountPath: /csi
name: socket-dir
resources:
limits:
memory: 500Mi
requests:
cpu: 10m
memory: 20Mi
- name: beegfs
image: ghcr.io/thinkparq/beegfs-csi-driver:v1.6.0
args:
Expand Down
10 changes: 8 additions & 2 deletions deploy/k8s/bases/csi-beegfs-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ metadata:
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
verbs: ["get", "list", "watch", "create", "delete", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
Expand All @@ -40,6 +40,12 @@ rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["patch"]

---

Expand Down
2 changes: 1 addition & 1 deletion examples/k8s/dyn/dyn-sc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ parameters:
# permissions/mode: "0644"
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: false
allowVolumeExpansion: true
13 changes: 12 additions & 1 deletion pkg/beegfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
// controllerCaps represents the capabilities of the controller service
controllerCaps = []csi.ControllerServiceCapability_RPC_Type{
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
}
)

Expand Down Expand Up @@ -378,7 +379,17 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
}

func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
volumeID := req.GetVolumeId()
if len(volumeID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Volume ID not provided")
}
// While currently volume "capacity" has no meaning as far as the driver is concerned, some
// applications rely on the capacity of the PV/PVC in the K8s API to make certain decisions.
// For these applications it is helpful to support volume resizing.
return &csi.ControllerExpandVolumeResponse{
CapacityBytes: req.CapacityRange.RequiredBytes,
NodeExpansionRequired: false,
}, nil
}

func (cs *controllerServer) ControllerGetVolume(ctx context.Context, in *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error) {
Expand Down
7 changes: 7 additions & 0 deletions pkg/beegfs/identityserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.G
},
},
},
{
Type: &csi.PluginCapability_VolumeExpansion_{
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
Type: csi.PluginCapability_VolumeExpansion_ONLINE,
},
},
},
},
}, nil
}
2 changes: 1 addition & 1 deletion test/e2e/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func initBaseBeegfsDriver(dynamicVolDirBasePathBeegfsRoot, staticVolDirPathBeegf
storageframework.CapPVCDataSource: false,
storageframework.CapMultiPODs: true,
storageframework.CapRWX: true,
storageframework.CapControllerExpansion: false,
storageframework.CapControllerExpansion: true,
storageframework.CapNodeExpansion: false,
storageframework.CapVolumeLimits: false,
// This setting is only used in two places, both in the multivolume test suite. Setting this to true
Expand Down

0 comments on commit 4f37cf1

Please sign in to comment.