Skip to content

Commit 04f8b28

Browse files
committed
feat(k8s): update sfs
1 parent 182e3e6 commit 04f8b28

File tree

1 file changed

+261
-0
lines changed

1 file changed

+261
-0
lines changed
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
---
2+
title: How to use SFS with Kubernetes Kapsule
3+
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.
4+
tags: kubernetes kubernetes-kapsule kapsule sfs
5+
dates:
6+
validation: 2025-01-13
7+
posted: 2023-12-27
8+
categories:
9+
- containers
10+
- kubernetes
11+
---
12+
import Requirements from '@macros/iam/requirements.mdx'
13+
14+
The Scaleway File Storage Container Storage Interface (CSI) driver enables Kubernetes users to manage Scaleway File Storage volumes within their clusters.
15+
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/).
16+
17+
## Supported features
18+
19+
The Scaleway File Storage CSI driver supports the following features:
20+
21+
- Dynamic provisioning: Automatically create Scaleway File Storage volumes using PVCs and StorageClasses.
22+
- `ReadWriteMany` access mode: Allows multiple pods to read from and write to the same file storage volume simultaneously.
23+
- Import of existing Volumes: Integrate pre-existing Scaleway File Storage volumes into Kubernetes.
24+
- Custom storage classes: Define specific parameters, such as file system type (e.g., ext4), for volumes.
25+
26+
<Requirements />
27+
28+
- A Scaleway account logged into the [console](https://console.scaleway.com)
29+
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
30+
- [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.
33+
34+
## Installation
35+
36+
The Scaleway File Storage CSI driver can be installed using Helm. Follow these steps to deploy the driver in your Kubernetes Kapsule cluster:
37+
38+
1. Add the Scaleway Helm repository:
39+
```bash
40+
helm repo add scaleway https://helm.scw.cloud/
41+
helm repo update
42+
```
43+
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:
45+
```bash
46+
helm upgrade --install scaleway-filestorage-csi --namespace kube-system scaleway/scaleway-filestorage-csi \
47+
--set controller.scaleway.env.SCW_DEFAULT_ZONE=fr-par-1 \
48+
--set controller.scaleway.env.SCW_DEFAULT_PROJECT_ID=<your-project-id> \
49+
--set controller.scaleway.env.SCW_ACCESS_KEY=<your-access-key> \
50+
--set controller.scaleway.env.SCW_SECRET_KEY=<your-secret-key>
51+
```
52+
53+
Replace `<your-project-id>`, `<your-access-key>`, and `<your-secret-key>` with your Scaleway credentials.
54+
55+
3. Check that the CSI driver pods are running in the `kube-system` namespace:
56+
```bash
57+
kubectl get pods -n kube-system -l app=scaleway-filestorage-csi
58+
```
59+
60+
You should see the `scaleway-filestorage-csi-controller` and `scaleway-filestorage-csi-node` pods in a `Running` state.
61+
62+
## Using the Scaleway File Storage CSI Driver
63+
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.
65+
66+
### Creating a Persistent Volume Claim (PVC)
67+
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 PVC**:
71+
Create a file named `pvc.yaml` with the following content:
72+
73+
```yaml
74+
apiVersion: v1
75+
kind: PersistentVolumeClaim
76+
metadata:
77+
name: my-file-pvc
78+
spec:
79+
accessModes:
80+
- ReadWriteMany
81+
resources:
82+
requests:
83+
storage: 10Gi
84+
storageClassName: scaleway-file-default
85+
```
86+
87+
Apply the PVC:
88+
```bash
89+
kubectl apply -f pvc.yaml
90+
```
91+
92+
2. Create a file named `pod.yaml` to define a pod that uses the PVC:
93+
94+
```yaml
95+
apiVersion: v1
96+
kind: Pod
97+
metadata:
98+
name: my-file-app
99+
spec:
100+
containers:
101+
- name: busybox
102+
image: busybox
103+
command: ["sleep", "3600"]
104+
volumeMounts:
105+
- mountPath: "/data"
106+
name: file-volume
107+
volumes:
108+
- name: file-volume
109+
persistentVolumeClaim:
110+
claimName: my-file-pvc
111+
```
112+
113+
Apply the pod configuration:
114+
```bash
115+
kubectl apply -f pod.yaml
116+
```
117+
118+
3. Check that the pod is running and the volume is mounted:
119+
```bash
120+
kubectl get pods
121+
kubectl exec -it my-file-app -- df -h /data
122+
```
123+
124+
The output should show the mounted Scaleway File Storage volume at `/data`.
125+
126+
### Importing an existing File Storage volume
127+
128+
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.
129+
130+
1. Create a file named `pv-import.yaml` to define a PV that references an existing Scaleway File Storage volume:
131+
132+
```yaml
133+
apiVersion: v1
134+
kind: PersistentVolume
135+
metadata:
136+
name: my-imported-pv
137+
spec:
138+
capacity:
139+
storage: 10Gi
140+
accessModes:
141+
- ReadWriteMany
142+
persistentVolumeReclaimPolicy: Retain
143+
storageClassName: scaleway-file-default
144+
csi:
145+
driver: filestorage.csi.scaleway.com
146+
volumeHandle: fr-par-1/<volume-id>
147+
volumeAttributes:
148+
zone: fr-par-1
149+
```
150+
151+
Replace `<volume-id>` with the ID of the existing Scaleway File Storage volume.
152+
153+
Apply the PV:
154+
```bash
155+
kubectl apply -f pv-import.yaml
156+
```
157+
158+
2. Create a file named `pvc-import.yaml` to define a PVC that binds to the imported PV:
159+
160+
```yaml
161+
apiVersion: v1
162+
kind: PersistentVolumeClaim
163+
metadata:
164+
name: my-imported-pvc
165+
spec:
166+
accessModes:
167+
- ReadWriteMany
168+
resources:
169+
requests:
170+
storage: 10Gi
171+
storageClassName: scaleway-file-default
172+
volumeName: my-imported-pv
173+
```
174+
175+
Apply the PVC:
176+
```bash
177+
kubectl apply -f pvc-import.yaml
178+
```
179+
180+
3. Create a pod that uses the imported PVC, similar to the previous example:
181+
182+
```yaml
183+
apiVersion: v1
184+
kind: Pod
185+
metadata:
186+
name: my-imported-file-app
187+
spec:
188+
containers:
189+
- name: busybox
190+
image: busybox
191+
command: ["sleep", "3600"]
192+
volumeMounts:
193+
- mountPath: "/data"
194+
name: file-volume
195+
volumes:
196+
- name: file-volume
197+
persistentVolumeClaim:
198+
claimName: my-imported-pvc
199+
```
200+
201+
Apply the pod configuration:
202+
```bash
203+
kubectl apply -f pod.yaml
204+
```
205+
206+
4. Verify that the pod is running and the imported volume is mounted:
207+
```bash
208+
kubectl get pods
209+
kubectl exec -it my-imported-file-app -- ls /data
210+
```
211+
212+
The output should list the contents of the imported Scaleway File Storage volume.
213+
214+
### Using a custom storage class
215+
216+
You can customize the storage class to define specific parameters for Scaleway File Storage volumes, such as the file system type.
217+
218+
1. Create a file named `storageclass.yaml` with the following content:
219+
220+
```yaml
221+
kind: StorageClass
222+
apiVersion: storage.k8s.io/v1
223+
metadata:
224+
name: my-file-storage-class
225+
provisioner: filestorage.csi.scaleway.com
226+
reclaimPolicy: Delete
227+
parameters:
228+
csi.storage.k8s.io/fstype: ext4
229+
```
230+
231+
Apply the storage class:
232+
```bash
233+
kubectl apply -f storageclass.yaml
234+
```
235+
236+
2. Modify the PVC from the first example to use the custom storage class:
237+
238+
```yaml
239+
apiVersion: v1
240+
kind: PersistentVolumeClaim
241+
metadata:
242+
name: my-custom-file-pvc
243+
spec:
244+
accessModes:
245+
- ReadWriteMany
246+
resources:
247+
requests:
248+
storage: 10Gi
249+
storageClassName: my-file-storage-class
250+
```
251+
252+
Apply the PVC:
253+
```bash
254+
kubectl apply -f pvc.yaml
255+
```
256+
257+
3. Check that the PVC is created with the custom storage class:
258+
```bash
259+
kubectl get pvc
260+
kubectl describe pvc my-custom-file-pvc
261+
```

0 commit comments

Comments
 (0)