Skip to content

Commit 02345b9

Browse files
committed
feat(k8s): use sfs
1 parent 43f4452 commit 02345b9

File tree

1 file changed

+101
-86
lines changed

1 file changed

+101
-86
lines changed

pages/kubernetes/how-to/use-sfs-with-kubernetes.mdx

Lines changed: 101 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ title: How to use SFS with Kubernetes Kapsule
33
description: This page explains how to use the Scaleway File Storage Container Storage Interface (CSI) driver to enable Kubernetes users to manage Scaleway File Storage volumes within their clusters.
44
tags: kubernetes kubernetes-kapsule kapsule sfs
55
dates:
6-
validation: 2025-01-13
7-
posted: 2023-12-27
6+
validation: 2025-07-18
7+
posted: 2025-07-18
88
categories:
99
- containers
1010
- kubernetes
1111
---
1212
import Requirements from '@macros/iam/requirements.mdx'
1313

14-
The Scaleway File Storage Container Storage Interface (CSI) driver enables Kubernetes users to manage Scaleway File Storage volumes within their clusters.
14+
The Scaleway File Storage Container Storage Interface (CSI) driver enables Kubernetes users to manage Scaleway File Storage volumes within their clusters.
1515
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](https://www.scaleway.com/en/file-storage/).
1616

1717
## Supported features
@@ -28,8 +28,8 @@ The Scaleway File Storage CSI driver supports the following features:
2828
- A Scaleway account logged into the [console](https://console.scaleway.com)
2929
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
3030
- [Created](/kubernetes/how-to/create-cluster/) a Kubernetes Kapsule cluster
31-
- Helm installed for deploying the CSI driver.
32-
- Access to the Scaleway File Storage API.
31+
- Helm installed for deploying the CSI driver
32+
- Access to the Scaleway File Storage API
3333

3434
## Installation
3535

@@ -39,9 +39,10 @@ The Scaleway File Storage CSI driver can be installed using Helm. Follow these s
3939
```bash
4040
helm repo add scaleway https://helm.scw.cloud/
4141
helm repo update
42-
```
42+
```
43+
44+
2. Deploy the Scaleway File Storage CSI Driver:
4345

44-
2. Deploy the Scaleway File Storage CSI Driver. Use the Helm chart to install the driver, configuring it with your Scaleway credentials and default zone:
4546
```bash
4647
helm upgrade --install scaleway-filestorage-csi --namespace kube-system scaleway/scaleway-filestorage-csi \
4748
--set controller.scaleway.env.SCW_DEFAULT_ZONE=fr-par-1 \
@@ -52,7 +53,8 @@ The Scaleway File Storage CSI driver can be installed using Helm. Follow these s
5253

5354
Replace `<your-project-id>`, `<your-access-key>`, and `<your-secret-key>` with your Scaleway credentials.
5455

55-
3. Check that the CSI driver pods are running in the `kube-system` namespace:
56+
3. Check that the CSI driver pods are running:
57+
5658
```bash
5759
kubectl get pods -n kube-system -l app=scaleway-filestorage-csi
5860
```
@@ -61,100 +63,105 @@ The Scaleway File Storage CSI driver can be installed using Helm. Follow these s
6163

6264
## Using the Scaleway File Storage CSI Driver
6365

64-
The Scaleway File Storage CSI driver supports dynamic provisioning of Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) in Kubernetes. Below are examples of how to use the driver to create and manage file storage volumes.
66+
The CSI driver supports dynamic provisioning of Persistent Volumes (PVs) and Persistent Volume Claims (PVCs).
6567

6668
### Creating a Persistent Volume Claim (PVC)
6769

68-
This example demonstrates how to create a PVC to dynamically provision a Scaleway File Storage volume and use it in a pod.
69-
70-
1. Create a file named `pvc.yaml` with the following content:
70+
1. Create a file named `pvc.yaml`:
7171

7272
```yaml
7373
apiVersion: v1
7474
kind: PersistentVolumeClaim
7575
metadata:
76-
name: my-file-pvc
76+
name: my-pvc
7777
spec:
7878
accessModes:
7979
- ReadWriteMany
8080
resources:
8181
requests:
82-
storage: 10Gi
83-
storageClassName: scaleway-file-default
82+
storage: 100Gi
83+
storageClassName: scw-fs
8484
```
8585
86-
Apply the PVC:
86+
Apply it:
87+
8788
```bash
8889
kubectl apply -f pvc.yaml
8990
```
9091

91-
2. Create a file named `pod.yaml` to define a pod that uses the PVC:
92+
2. Create a file named `pod.yaml`:
9293

9394
```yaml
9495
apiVersion: v1
9596
kind: Pod
9697
metadata:
97-
name: my-file-app
98+
name: my-app
9899
spec:
99100
containers:
100-
- name: busybox
101-
image: busybox
102-
command: ["sleep", "3600"]
103-
volumeMounts:
104-
- mountPath: "/data"
105-
name: file-volume
101+
- name: my-busybox
102+
image: busybox
103+
volumeMounts:
104+
- name: my-volume
105+
mountPath: "/data"
106+
command: ["/bin/sh", "-c"]
107+
args: ["tail -f /dev/null"]
106108
volumes:
107-
- name: file-volume
108-
persistentVolumeClaim:
109-
claimName: my-file-pvc
109+
- name: my-volume
110+
persistentVolumeClaim:
111+
claimName: my-pvc
110112
```
111113
112114
Apply the pod configuration:
115+
113116
```bash
114117
kubectl apply -f pod.yaml
115118
```
116119

117-
3. Check that the pod is running and the volume is mounted:
120+
3. Verify the mount:
121+
118122
```bash
119123
kubectl get pods
120-
kubectl exec -it my-file-app -- df -h /data
124+
kubectl exec -it my-app -- df -h /data
121125
```
122126

123-
The output should show the mounted Scaleway File Storage volume at `/data`.
124-
125127
### Importing an existing File Storage volume
126128

127-
You can import an existing Scaleway File Storage volume into Kubernetes using the Scaleway File Storage CSI driver. This is useful for integrating pre-existing storage volumes into your cluster.
128-
129-
1. Create a file named `pv-import.yaml` to define a PV that references an existing Scaleway File Storage volume:
129+
1. Create a `pv-import.yaml` file:
130130

131131
```yaml
132132
apiVersion: v1
133133
kind: PersistentVolume
134134
metadata:
135-
name: my-imported-pv
135+
name: test-pv
136136
spec:
137137
capacity:
138-
storage: 10Gi
138+
storage: 100Gi
139+
volumeMode: Filesystem
139140
accessModes:
140141
- ReadWriteMany
141-
persistentVolumeReclaimPolicy: Retain
142-
storageClassName: scaleway-file-default
142+
storageClassName: scw-fs
143143
csi:
144144
driver: filestorage.csi.scaleway.com
145-
volumeHandle: fr-par-1/<volume-id>
146-
volumeAttributes:
147-
zone: fr-par-1
145+
volumeHandle: fr-par/11111111-1111-1111-111111111111
146+
nodeAffinity:
147+
required:
148+
nodeSelectorTerms:
149+
- matchExpressions:
150+
- key: topology.filestorage.csi.scaleway.com/region
151+
operator: In
152+
values:
153+
- fr-par
148154
```
149155
150-
Replace `<volume-id>` with the ID of the existing Scaleway File Storage volume.
156+
Replace `volumeHandle` with the actual ID of your existing volume.
157+
158+
Apply:
151159

152-
Apply the PV:
153160
```bash
154161
kubectl apply -f pv-import.yaml
155162
```
156163

157-
2. Create a file named `pvc-import.yaml` to define a PVC that binds to the imported PV:
164+
2. Create `pvc-import.yaml`:
158165

159166
```yaml
160167
apiVersion: v1
@@ -166,95 +173,103 @@ You can import an existing Scaleway File Storage volume into Kubernetes using th
166173
- ReadWriteMany
167174
resources:
168175
requests:
169-
storage: 10Gi
170-
storageClassName: scaleway-file-default
171-
volumeName: my-imported-pv
176+
storage: 100Gi
177+
storageClassName: scw-fs
178+
volumeName: test-pv
172179
```
173180

174-
Apply the PVC:
181+
Apply:
182+
175183
```bash
176184
kubectl apply -f pvc-import.yaml
177185
```
178186

179-
3. Create a pod that uses the imported PVC, similar to the previous example:
187+
3. Create the pod (reuse the example from earlier with `claimName: my-imported-pvc`):
180188

181189
```yaml
182190
apiVersion: v1
183191
kind: Pod
184192
metadata:
185-
name: my-imported-file-app
193+
name: my-imported-app
186194
spec:
187195
containers:
188-
- name: busybox
189-
image: busybox
190-
command: ["sleep", "3600"]
191-
volumeMounts:
192-
- mountPath: "/data"
193-
name: file-volume
196+
- name: my-busybox
197+
image: busybox
198+
volumeMounts:
199+
- name: my-volume
200+
mountPath: "/data"
201+
command: ["/bin/sh", "-c"]
202+
args: ["tail -f /dev/null"]
194203
volumes:
195-
- name: file-volume
196-
persistentVolumeClaim:
197-
claimName: my-imported-pvc
204+
- name: my-volume
205+
persistentVolumeClaim:
206+
claimName: my-imported-pvc
198207
```
199208

200-
Apply the pod configuration:
209+
Apply:
210+
201211
```bash
202212
kubectl apply -f pod.yaml
203213
```
204214

205-
4. Verify that the pod is running and the imported volume is mounted:
215+
4. Verify:
216+
206217
```bash
207218
kubectl get pods
208-
kubectl exec -it my-imported-file-app -- ls /data
219+
kubectl exec -it my-imported-app -- ls /data
209220
```
210221

211-
The output should list the contents of the imported Scaleway File Storage volume.
212-
213222
### Using a custom storage class
214223

215-
You can customize the storage class to define specific parameters for Scaleway File Storage volumes, such as the file system type.
216-
217-
1. Create a file named `storageclass.yaml` with the following content:
224+
1. Create `storageclass.yaml`:
218225

219226
```yaml
220-
kind: StorageClass
221227
apiVersion: storage.k8s.io/v1
228+
kind: StorageClass
222229
metadata:
223-
name: my-file-storage-class
230+
name: my-default-storage-class
231+
annotations:
232+
storageclass.kubernetes.io/is-default-class: "true"
224233
provisioner: filestorage.csi.scaleway.com
225234
reclaimPolicy: Delete
226-
parameters:
227-
csi.storage.k8s.io/fstype: ext4
228235
```
229236

230-
Apply the storage class:
237+
Apply:
238+
231239
```bash
232240
kubectl apply -f storageclass.yaml
233241
```
234242

235-
2. Modify the PVC from the first example to use the custom storage class:
243+
2. Update the PVC to use this storage class:
236244

237245
```yaml
238246
apiVersion: v1
239247
kind: PersistentVolumeClaim
240248
metadata:
241-
name: my-custom-file-pvc
249+
name: my-pvc
242250
spec:
243251
accessModes:
244252
- ReadWriteMany
245253
resources:
246254
requests:
247-
storage: 10Gi
248-
storageClassName: my-file-storage-class
249-
```
250-
251-
Apply the PVC:
252-
```bash
253-
kubectl apply -f pvc.yaml
255+
storage: 100Gi
256+
storageClassName: my-default-storage-class
254257
```
255258

256-
3. Check that the PVC is created with the custom storage class:
257-
```bash
258-
kubectl get pvc
259-
kubectl describe pvc my-custom-file-pvc
260-
```
259+
### Specifying the region
260+
261+
To specify a region explicitly for volume creation:
262+
263+
```yaml
264+
apiVersion: storage.k8s.io/v1
265+
kind: StorageClass
266+
metadata:
267+
name: my-ams-storage-class
268+
provisioner: filestorage.csi.scaleway.com
269+
reclaimPolicy: Delete
270+
allowedTopologies:
271+
- matchLabelExpressions:
272+
- key: topology.filestorage.csi.scaleway.com/region
273+
values:
274+
- nl-ams
275+
```

0 commit comments

Comments
 (0)