How to use SFS with Kubernetes Kapsule
The Scaleway File Storage Container Storage Interface (CSI) driver enables Kubernetes users to manage Scaleway File Storage file systems within their clusters.
The Scaleway File Storage CSI driver is designed to work with Kubernetes Kapsule and Kosmos clusters, providing a standardized interface to create, manage, and attach file storage volumes to your containerized workloads. For more details on Scaleway File Storage, refer to the Scaleway File Storage documentation.
Supported features
The Scaleway File Storage CSI driver supports the following features:
- Dynamic provisioning: Automatically create Scaleway File Storage volumes using PVCs and StorageClasses.
- Import of existing Volumes: Integrate pre-existing Scaleway File Storage volumes into Kubernetes.
- Volume upsizing: The size of the volume can be increased without the need to detach the file system
ReadWriteOnceaccess mode: The volume can be mounted as read-write by a single node.ReadOnlyManyaccess mode: The volume can be mounted read-only by many nodes.ReadWriteManyaccess mode: The volume can be mounted as read-write by many nodes.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- Created a Kubernetes Kapsule cluster
- Installed the Kubernetes command-line tool
kubectl - Added the tag
scw-filestorage-csito your Kubernetes Kapsule cluster - Access to the Scaleway File Storage API
Installation
The Scaleway File Storage CSI driver is preinstalled on Scaleway's managed Kubernetes.
You can run the following command to check that the CSI driver pods are running:
kubectl get pods -n kube-system -l app=filestorage-csi-nodeYou should see the filestorage-csi-node pods in a Running state.
If you don't see any pod after running the previous command, make sure the filestorage-csi-node DaemonSet is present in your cluster ($ kubectl get daemonset -n kube-system filestorage-csi-node) and you have at least one pool with POP2 Instances.
Using the Scaleway File Storage CSI Driver
The CSI driver supports dynamic provisioning of Persistent Volumes (PVs) and Persistent Volume Claims (PVCs).
Creating a Persistent Volume Claim (PVC)
-
Create a file named
pvc.yaml:apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteMany resources: requests: storage: 100G storageClassName: scw-fsApply it:
kubectl apply -f pvc.yaml -
Create a file named
pod.yaml:apiVersion: v1 kind: Pod metadata: name: my-app spec: containers: - name: my-busybox image: busybox volumeMounts: - name: my-volume mountPath: "/data" command: ["/bin/sh", "-c"] args: ["tail -f /dev/null"] volumes: - name: my-volume persistentVolumeClaim: claimName: my-pvcApply the pod configuration:
kubectl apply -f pod.yaml -
Verify the mount:
kubectl get pods kubectl exec -it my-app -- df -h /data
Importing an existing File Storage volume
-
Create a
pv-import.yamlfile:apiVersion: v1 kind: PersistentVolume metadata: name: test-pv spec: capacity: storage: 100G volumeMode: Filesystem accessModes: - ReadWriteMany storageClassName: scw-fs csi: driver: filestorage.csi.scaleway.com volumeHandle: fr-par/11111111-1111-1111-111111111111 nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: topology.filestorage.csi.scaleway.com/region operator: In values: - fr-parReplace
volumeHandlewith the actual ID of your existing volume.Apply:
kubectl apply -f pv-import.yaml -
Create
pvc-import.yaml:apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-imported-pvc spec: accessModes: - ReadWriteMany resources: requests: storage: 100G storageClassName: scw-fs volumeName: test-pvApply:
kubectl apply -f pvc-import.yaml -
Create the pod (reuse the example from earlier with
claimName: my-imported-pvc):apiVersion: v1 kind: Pod metadata: name: my-imported-app spec: containers: - name: my-busybox image: busybox volumeMounts: - name: my-volume mountPath: "/data" command: ["/bin/sh", "-c"] args: ["tail -f /dev/null"] volumes: - name: my-volume persistentVolumeClaim: claimName: my-imported-pvcApply:
kubectl apply -f pod.yaml -
Verify:
kubectl get pods kubectl exec -it my-imported-app -- ls /data
Using a custom storage class
-
Create
storageclass.yaml:apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: my-default-storage-class provisioner: filestorage.csi.scaleway.com reclaimPolicy: DeleteApply:
kubectl apply -f storageclass.yaml -
Update the PVC to use this storage class:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteMany resources: requests: storage: 100G storageClassName: my-default-storage-class
Specifying the region
To specify a region explicitly for volume creation:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: my-par-storage-class
provisioner: filestorage.csi.scaleway.com
reclaimPolicy: Delete
allowedTopologies:
- matchLabelExpressions:
- key: topology.filestorage.csi.scaleway.com/region
values:
- fr-par