Skip to content

Commit d8892d0

Browse files
committed
feat(k8s): tuto
1 parent 71f1ece commit d8892d0

File tree

1 file changed

+32
-49
lines changed
  • tutorials/migrate-k8s-persistent-volumes-to-multi-az

1 file changed

+32
-49
lines changed

tutorials/migrate-k8s-persistent-volumes-to-multi-az/index.mdx

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ dates:
1313
posted: 2025-01-30
1414
---
1515

16-
Historically, Scaleway Kapsule clusters were single-zone, meaning workloads and their associated storage were confined to a single location. With the introduction of multi-zone support, distributing workloads across multiple zones can enhance availability and fault tolerance.
17-
18-
This tutorial provides a generalized approach to migrating Persistent Volumes (PVs) from one zone to another in a Scaleway Kapsule multi-zone cluster, applicable to various applications.
16+
Historically, Scaleway Kapsule clusters were single-zone, meaning workloads and their associated storage were confined to a single location. With the introduction of multi-zone support, distributing workloads across multiple zones can enhance availability and fault tolerance. This tutorial provides a generalized approach to migrating Persistent Volumes (PVs) from one zone to another in a Scaleway Kapsule multi-zone cluster, applicable to various applications.
1917

2018
<Macro id="requirements" />
21-
2219
- A Scaleway account logged into the [console](https://console.scaleway.com)
2320
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
2421
- [Created a Kapsule cluster](/kubernetes/how-to/create-cluster/) with multi-zone support enabled
@@ -28,34 +25,28 @@ This tutorial provides a generalized approach to migrating Persistent Volumes (P
2825
- Familiarity with Kubernetes Persistent Volumes, `StatefulSets`, and Storage Classes.
2926

3027
<Message type="important">
31-
**Backing up your data is crucial before making any changes.**
32-
Ensure you have a backup strategy in place. You can use tools like [Velero](/tutorials/k8s-velero-backup/) for Kubernetes backups or manually copy data to another storage solution. Always verify the integrity of your backups before proceeding.
28+
**Backing up your data is crucial before making any changes.**
29+
Ensure you have a backup strategy in place. You can use tools like [Velero](/tutorials/k8s-velero-backup/) for Kubernetes backups or manually copy data to another storage solution. Always verify the integrity of your backups before proceeding.
3330
</Message>
3431

3532
## Identify existing Persistent Volumes
3633

3734
1. Use `kubectl` to interact with your cluster and list the Persistent Volumes in your cluster:
38-
```sh
39-
kubectl get pv
40-
```
41-
42-
2. Identify the volumes attached to your StatefulSet and note their `PersistentVolumeClaim` (PVC) names and `StorageClass`.
43-
Example output:
44-
```plaintext
45-
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS ZONE
46-
pvc-123abc 10Gi RWO Retain Bound default/my-app-pvc scw-bssd fr-par-1
47-
```
48-
To find the `VOLUME_ID`, correlate this with the scw command output:
49-
```
50-
scw instance volume list
51-
```
52-
53-
3. To find the `VOLUME_ID` associated with a PV, correlate it with the output of the following command:
35+
```sh
36+
kubectl get pv
37+
```
38+
2. Identify the volumes attached to your StatefulSet and note their `PersistentVolumeClaim` (PVC) names and `StorageClass`. To find the `VOLUME_ID` associated with a PV, correlate the PV's details with the output of the following command:
39+
```sh
40+
scw instance volume list
41+
```
42+
3. Match the PV's details with the corresponding volume in the Scaleway Instance list to identify the correct `VOLUME_ID`.
5443

55-
```sh
56-
scw instance volume list
57-
```
58-
Match the PV's details with the corresponding volume in the Scaleway Instance list to identify the correct `VOLUME_ID`.
44+
**Example output:**
45+
```plaintext
46+
NAMECAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIMSTORAGECLASS ZONE
47+
pvc-123abc 10Gi RWORetain Bounddefault/my-app-pvc scw-bssd fr-par-1
48+
```
49+
To find the `VOLUME_ID`, correlate this with the output of the `scw instance volume list` command.
5950

6051
## Create snapshots of your existing Persistent Volumes
6152

@@ -65,12 +56,10 @@ Use the Scaleway CLI to create snapshots of your volumes.
6556
```sh
6657
scw instance volume list
6758
```
68-
6959
2. Create a snapshot for each volume:
7060
```sh
7161
scw instance snapshot create volume-id=<VOLUME_ID> name=my-app-snapshot
7262
```
73-
7463
3. Verify snapshot creation:
7564
```sh
7665
scw instance snapshot list
@@ -86,14 +75,14 @@ scw instance volume create name=my-app-volume-new size=10GB type=bssd snapshot-i
8675

8776
Repeat this for each zone required.
8877

89-
<Meessage type="tip">
90-
Choose zones based on your distribution strategy. Check Scaleway's [zone availability](/account/reference-content/products-availability/) for optimal placement.
78+
<Message type="tip">
79+
Choose zones based on your distribution strategy. Check Scaleway's [zone availability](/account/reference-content/products-availability/) for optimal placement.
9180
</Message>
9281

9382
## Update Persistent Volume Claims (PVCs)
9483

9584
<Message type="important">
96-
Deleting a PVC can lead to data loss if not managed correctly. Ensure your application is scaled down or data is backed up.
85+
Deleting a PVC can lead to data loss if not managed correctly. Ensure your application is scaled down or data is backed up.
9786
</Message>
9887

9988
Modify your `PersistentVolumeClaims` to reference the newly created volumes.
@@ -102,13 +91,11 @@ Modify your `PersistentVolumeClaims` to reference the newly created volumes.
10291
```sh
10392
kubectl scale statefulset my-app --replicas=0
10493
```
105-
106-
2. Delete the existing PVC (PVCs are immutable and cannot be updated directly):
94+
2. Delete the existing PVC:
10795
```sh
10896
kubectl delete pvc my-app-pvc
10997
```
110-
111-
3. Create a new PVC with a multi-zone compatible `StorageClass`:
98+
3. Create a new PVC with a multi-zone compatible `StorageClass`. Here is an example YAML file:
11299
```yaml
113100
apiVersion: v1
114101
kind: PersistentVolumeClaim
@@ -122,17 +109,14 @@ Modify your `PersistentVolumeClaims` to reference the newly created volumes.
122109
requests:
123110
storage: 10Gi
124111
```
125-
126112
4. Apply the updated PVCs:
127113
```sh
128114
kubectl apply -f my-app-pvc.yaml
129115
```
130116

131117
## Reconfigure the StatefulSet to use multi-zone volumes
132118

133-
1. Edit the `StatefulSet` definition to use the newly created Persistent Volume Claims.
134-
Example configuration:
135-
119+
1. Edit the `StatefulSet` definition to use the newly created Persistent Volume Claims. Here is an example configuration:
136120
```yaml
137121
apiVersion: apps/v1
138122
kind: StatefulSet
@@ -150,7 +134,6 @@ Modify your `PersistentVolumeClaims` to reference the newly created volumes.
150134
requests:
151135
storage: 10Gi
152136
```
153-
154137
2. Apply the `StatefulSet` changes:
155138
```sh
156139
kubectl apply -f my-app-statefulset.yaml
@@ -162,37 +145,37 @@ Modify your `PersistentVolumeClaims` to reference the newly created volumes.
162145
```sh
163146
kubectl get pods -o wide
164147
```
165-
166148
2. Ensure that the new Persistent Volumes are bound and correctly distributed across the zones:
167149
```sh
168150
kubectl get pv
169151
```
170152

171153
## Considerations for volume expansion
172154

173-
If you need to **resize the Persistent Volume**, ensure that the `StorageClass` supports volume expansion.
155+
If you need to **resize the Persistent Volume**, ensure that the `StorageClass` supports volume expansion.
174156

175157
1. Check if the feature is enabled:
176158
```sh
177159
kubectl get storageclass scw-bssd-multi-zone -o yaml | grep allowVolumeExpansion
178160
```
179-
180161
2. If `allowVolumeExpansion: true` is present, you can modify your PVC:
181162
```yaml
182163
spec:
183-
resources:
164+
resources:
184165
requests:
185-
storage: 20Gi
166+
storage: 20Gi
186167
```
187-
188168
3. Then apply the change:
189169
```sh
190170
kubectl apply -f my-app-pvc.yaml
191171
```
192172

193-
## Conclusion
173+
## Troubleshooting
194174

195-
You have successfully migrated your Persistent Volumes to a multi-zone Kapsule setup. Your `StatefulSet` is now distributed across multiple zones, improving resilience and availability.
175+
- **Persistent Volume not bound:** Ensure that the `StorageClass` and zone settings are correct.
176+
- **Application not scaling:** Check the StatefulSet configuration and PVC settings.
177+
- **Data integrity issues:** Verify the integrity of your backups before proceeding with any changes.
196178

197-
For further optimization, consider implementing [Pod anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) rules to ensure an even distribution of workloads across zones.
179+
## Conclusion
198180

181+
You have successfully migrated your Persistent Volumes to a multi-zone Kapsule setup. Your `StatefulSet` is now distributed across multiple zones, improving resilience and availability. For further optimization, consider implementing [Pod anti-affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) rules to ensure an even distribution of workloads across zones.

0 commit comments

Comments
 (0)