Skip to content

Commit 1742084

Browse files
authored
[K8S] Documentation csi v0.3 (#2642)
1 parent 52e6ca0 commit 1742084

File tree

1 file changed

+64
-165
lines changed

1 file changed

+64
-165
lines changed

containers/kubernetes/api-cli/managing-storage.mdx

Lines changed: 64 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ content:
77
paragraph: Learn how to manage Block Storage volumes using Scaleway's CSI driver on Kubernetes Kapsule and Kosmos clusters.
88
tags: block-storage scaleway-csi kubernetes pvc
99
dates:
10-
validation: 2024-06-17
10+
validation: 2024-09-25
1111
posted: 2021-08-12
1212
categories:
1313
- kubernetes
@@ -23,181 +23,80 @@ The [Scaleway Block Volume](https://www.scaleway.com/en/block-storage/) Containe
2323
- Your Scaleway Project or Organization ID
2424
- [Created](/containers/kubernetes/how-to/create-cluster/) a Kubernetes cluster running on Scaleway Instances (v1.21+)
2525

26-
## Features
26+
<Message type="tip">
27+
Refer to our video tutorial [Getting Started with Kubernetes Part 4 - Storage](/containers/kubernetes/videos/) to view a visual presentation and step-by-step guidance of how to manage Block Storage volumes on Kubernetes with the Scaleway CSI.
28+
</Message>
2729

28-
Following is a list of functionalities implemented by the Scaleway CSI driver.
30+
## Verification of CSI driver status
2931

30-
### Block device resizing
32+
To verify if the driver is running, use the following command:
3133

32-
The Scaleway CSI driver implements the resize feature ([example for Kubernetes](https://kubernetes.io/blog/2018/07/12/resizing-persistent-volumes-using-kubernetes/)). It allows an online resize (without the need to detach the block device). However, resizing can only be done upwards, decreasing a volume's size is not supported.
34+
```bash
35+
kubectl get csidriver
36+
```
3337

34-
### Raw Block Volume
38+
The output of this command provides a quick status update on the CSI plugin within your Kubernetes cluster. For the latest features and enhancements, consider upgrading to [release 0.3](https://github.com/scaleway/scaleway-csi/tree/release-0.3#block-storage-low-latency), which supports **[Block Storage low latency](/storage/block/quickstart/)** volumes.
3539

36-
[Raw Block Volumes](https://kubernetes.io/blog/2019/03/07/raw-block-volume-support-to-beta/) allows the block volume to be exposed directly to the container as a block device, instead of a mounted filesystem. To enable it, the `volumeMode` needs to be set to `Block`. For instance, here is a PVC in raw block volume mode:
40+
To identify your current CSI release version, navigate to the [Cockpit interface](/observability/cockpit/how-to/access-grafana-and-managed-dashboards/), specifically the **Kubernetes Cluster - Overview** dashboard.
3741

38-
```yaml
39-
apiVersion: v1
40-
kind: PersistentVolumeClaim
41-
metadata:
42-
name: my-raw-pvc
43-
spec:
44-
volumeMode: Block
45-
[...]
46-
```
42+
## Upgrading to CSI version 0.3
4743

48-
### At-Rest encryption
49-
50-
Support for volume encryption. [See in examples](https://github.com/scaleway/scaleway-csi/tree/master/examples/kubernetes/#encrypting-volumes)
51-
52-
### Volume snapshots
53-
54-
[Volume snapshots](https://kubernetes.io/docs/concepts/storage/volume-snapshots/) allow the user to create a snapshot of a specific block volume.
55-
56-
### Volume statistics
57-
58-
The Scaleway CSI driver implements the [`NodeGetVolumeStats`](https://github.com/container-storage-interface/spec/blob/master/spec.md/#nodegetvolumestats) CSI method. It is used to gather statistics about the used block volumes. In Kubernetes, `kubelet` exposes these metrics.
59-
60-
## Kubernetes
61-
62-
This section is Kubernetes specific. Note that Scaleway CSI driver may work for older Kubernetes version than those announced.
63-
The CSI driver allows you to use [Persistent Volumes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) in Kubernetes.
64-
65-
## Creating persistent volumes with Scaleway Block Storage
66-
67-
1. Create a [PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) and use it as a volume inside the pod of a deployment.
68-
```
69-
kubectl apply -f pvc-deployment/pvc.yaml
70-
```
71-
2. Create the deployment that will use this volume:
72-
```
73-
kubectl apply -f pvc-deployment/deployment.yaml
74-
```
75-
76-
## Creating raw block volumes
77-
78-
1. Create a block volume and make it available in the pod as a raw block device. In order to do so, `volumeMode` must be set to Block:
79-
```bash
80-
kubectl apply -f raw-volume/pvc.yaml
81-
```
82-
2. Create a pod that will use this raw volume. In order to do so, `volumesDevices` must be used, instead of the traditional `volumeMounts`:
83-
```bash
84-
kubectl apply -f raw-volume/pod.yaml
85-
```
86-
3. Exec into the container and use the volume as a classic block device:
87-
```bash
88-
kubectl exec -it my-awesome-block-volume-app sh
89-
/ # ls -al /dev/xvda
90-
brw-rw---- 1 root disk 8, 32 Mar 23 12:34 /dev/xvda
91-
/ # dd if=/dev/zero of=/dev/xvda bs=1024k count=100
92-
100+0 records in
93-
100+0 records out
94-
104857600 bytes (100.0MB) copied, 0.043702 seconds, 2.2GB/s
95-
```
96-
97-
## Importing existing Scaleway volumes
98-
99-
1. If you have an already existing volume, with the ID `11111111-1111-1111-111111111111` in the zone `fr-par-1`, you can import it by creating the following PV:
100-
```yaml
101-
apiVersion: v1
102-
kind: PersistentVolume
103-
metadata:
104-
name: test-pv
105-
spec:
106-
capacity:
107-
storage: 5Gi
108-
volumeMode: Filesystem
109-
accessModes:
110-
- ReadWriteOnce
111-
storageClassName: scw-bssd
112-
csi:
113-
driver: csi.scaleway.com
114-
volumeHandle: fr-par-1/11111111-1111-1111-111111111111
115-
nodeAffinity:
116-
required:
117-
nodeSelectorTerms:
118-
- matchExpressions:
119-
- key: topology.csi.scaleway.com/zone
120-
operator: In
121-
values:
122-
- fr-par-1
123-
```
124-
2. Once the PV is created, create a PVC with the same attributes (here scw-bssd as storage class and a size of 5Gi):
125-
```bash
126-
kubectl apply -f importing/pvc.yaml
127-
```
128-
3. Create a pod that uses this volume:
129-
```bash
130-
kubectl apply -f importing/pod.yaml
131-
```
132-
133-
## Encrypting volumes
134-
135-
This plugin supports at rest encryption of the volumes with Cryptsetup/LUKS.
136-
137-
### Storage Class parameters
138-
139-
In order to have an encrypted volume, `encrypted: true` needs to be added to the
140-
StorageClass parameters. You will also need a passphrase to encrypt/decrypt the volume,
141-
which is taken from the secrets passed to the `NodeStageVolume` and `NodeExpandVolume` method.
142-
143-
The [external-provisioner](https://github.com/kubernetes-csi/external-provisioner)
144-
can be used to [pass down the wanted secret to the CSI plugin](https://kubernetes-csi.github.io/docs/secrets-and-credentials-storage-class.html) (v1.0.1+).
145-
146-
Some additional parameters are needed on the StorageClass:
147-
148-
- `csi.storage.k8s.io/node-stage-secret-name`: The name of the secret
149-
- `csi.storage.k8s.io/node-stage-secret-namespace`: The namespace of the secret
150-
- `csi.storage.k8s.io/node-expand-secret-name`: The name of the secret (see note below).
151-
- `csi.storage.k8s.io/node-expand-secret-namespace`: The namespace of the secret (see note below).
152-
153-
> Volume expansion for encrypted volumes is only supported with the `CSINodeExpandSecret`
154-
> feature gate which is available since `v1.25.0` and by default since `v1.27.0`.
155-
156-
The secret needs to have the passphrase in the entry with the key `encryptionPassphrase`.
157-
158-
For instance, with the following secret:
159-
160-
```yaml
161-
apiVersion: v1
162-
kind: Secret
163-
metadata:
164-
name: enc-secret
165-
namespace: default
166-
type: Opaque
167-
data:
168-
encryptionPassphrase: bXlhd2Vzb21lcGFzc3BocmFzZQ==
169-
```
44+
### Using the API with curl
17045

171-
and the following StorageClass:
172-
173-
```yaml
174-
# Volume expansion is supported with CSINodeExpandSecret feature gate since v1.25.0 or by default since v1.27.0
175-
allowVolumeExpansion: true
176-
apiVersion: storage.k8s.io/v1
177-
kind: StorageClass
178-
metadata:
179-
name: "sbs-default-enc"
180-
provisioner: csi.scaleway.com
181-
reclaimPolicy: Delete
182-
volumeBindingMode: Immediate
183-
parameters:
184-
encrypted: "true"
185-
csi.storage.k8s.io/node-stage-secret-name: "enc-secret"
186-
csi.storage.k8s.io/node-stage-secret-namespace: "default"
187-
# Required for volume expansion
188-
csi.storage.k8s.io/node-expand-secret-name: "enc-secret"
189-
csi.storage.k8s.io/node-expand-secret-namespace: "default"
46+
You can trigger the migration to SBS-CSI using the following `curl` command:
47+
48+
```bash
49+
curl "https://api.scaleway.com/k8s/v1/regions/$REGION/clusters/$CLUSTER_ID/migrate-to-sbs-csi" \
50+
-X POST \
51+
-H "X-Auth-Token: $TOKEN"
19052
```
19153

192-
all the PVC created with the StorageClass `sbs-default-enc` will be encrypted at
193-
rest with the passphrase `myawesomepassphrase`.
54+
Replace the placeholders with the following:
19455

195-
The [Per Volume Secret](https://kubernetes-csi.github.io/docs/secrets-and-credentials-storage-class.html#per-volume-secrets)
196-
can also be used to avoid having one passphrase per StorageClass.
56+
- `$REGION`: Your cluster's region (e.g., `fr-par`, `nl-ams`).
57+
- `$CLUSTER_ID`: Your cluster ID.
58+
- `$TOKEN`: Your Scaleway API token.
19759

198-
<Message type="note">
199-
Note that before `v0.2.1` the expansion of encrypted volumes was not possible.
200-
`PersistentVolumes` created without the `csi.storage.k8s.io/node-stage-secret` annotations must be manually patched if the expansion is necessary. Be careful when doing so, as the required fields are immutable, and the patch will need to be forced. We recommend taking preventative measures such as backing up your data and switching the `reclaimPolicy` of the volume to `Retain`.
201-
</Message>
60+
This command will initiate the migration process for your cluster to the new SBS-CSI.
61+
62+
### Using the Scaleway CLI
20263

64+
Alternatively, you can use the Scaleway CLI to perform the migration. Ensure the CLI is installed and configured with your API credentials.
65+
66+
1. Install and configure the Scaleway CLI, if you have not already:
67+
```bash
68+
scw init
69+
```
70+
71+
2. Run the migration command:
72+
73+
```bash
74+
scw k8s cluster migrate-to-sbs-csi $CLUSTER_ID --region=$REGION
75+
```
76+
77+
Replace `$REGION` and `$CLUSTER_ID` with your cluster’s region and ID, respectively.
78+
79+
### Post-migration verification
80+
81+
After initiating the migration, the cluster status will change to _updating_. Once the migration completes, you can verify that the CSI driver has been updated and that the new driver properly handles Persistent Volume Claims (PVCs).
82+
83+
```bash
84+
kubectl get csidriver
85+
```
20386

87+
This command will confirm that the migration was successful.
88+
89+
## Going further
90+
91+
* [Creating persistent volumes with Scaleway Block Storage](hhttps://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#pvc--deployment)
92+
* [Creating raw block volumes](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#raw-block-volumes)
93+
* [Importing existing Scaleway volumes](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#importing-existing-scaleway-volumes)
94+
* [Creating volume snapshots](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#volume-snapshots)
95+
* [Importing volume snapshots](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#importing-snapshots)
96+
* [How to crate a storage class](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#different-storageclass)
97+
* [How to choose a zone for the volumes](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#specify-in-which-zone-the-volumes-are-going-to-be-created)
98+
* [How to choose the number of IOPS](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#choose-the-number-of-iops)
99+
<Message type="tip">
100+
* `sbs-5k` and `sbs-15k` are pre-configured storage classes designed to meet your IOPS requirements. You can achieve the equivalent of setting `iops:5k` in your custom class.
101+
</Message>
102+
* [Encrypting volumes](https://github.com/scaleway/scaleway-csi/tree/release-0.3/examples/kubernetes#encrypting-volumes)

0 commit comments

Comments
 (0)