Skip to content

Commit 5ea9a92

Browse files
committed
add walkthrough for pv snapshot and restore using aws providers
1 parent da1408b commit 5ea9a92

File tree

3 files changed

+217
-5
lines changed

3 files changed

+217
-5
lines changed

vcluster/deploy/control-plane/container/environment/eks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on [Amazon EKS](https://aws.amazon.com/.).
2626

2727
## Prerequisites
2828

29-
Before staring, ensure you have the following tools installed:
29+
Before starting, ensure you have the following tools installed:
3030

3131
- `kubectl` installed: Kubernetes command-line tool for interacting with the cluster. See [Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) for installation instructions.
3232
- `vCluster CLI` <InstallCli />

vcluster/manage/backup-restore/volume-snapshots.mdx renamed to vcluster/manage/backup-restore/volume-snapshots/README.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ sidebar_class_name: host-nodes private-nodes
77

88
import Tabs from '@theme/Tabs';
99
import TabItem from '@theme/TabItem';
10-
import TenancySupport from '../../_fragments/tenancy-support.mdx';
10+
import TenancySupport from '../../../_fragments/tenancy-support.mdx';
1111

1212
<TenancySupport hostNodes="true" privateNodes="true" />
1313

1414
:::warning
1515
This feature is currently in Beta.
16-
See vCluster [Lifecycle Policy](../../deploy/upgrade/supported_versions#feature-versioning) for more information.
16+
See vCluster [Lifecycle Policy](../../../deploy/upgrade/supported_versions#feature-versioning) for more information.
1717
:::
1818

1919
vCluster snapshots enable you to create volume snapshots for PersistentVolumeClaims that are provisioned by CSI drivers. This allows you to protect not only your virtual cluster resources and config, but also your application data.
2020

21-
See [how volume snapshots are created](../../understand/volume-snapshots) if you would like to learn more about volume snapshots and how vCluster creates them.
21+
See [how volume snapshots are created](../../../understand/volume-snapshots) if you would like to learn more about volume snapshots and how vCluster creates them.
2222

2323
:::important
2424
Volume snapshots can be created only for PVCs that are provisioned by CSI drivers with [Volume Snapshots](https://kubernetes.io/docs/concepts/storage/volume-snapshots/) support.
@@ -94,7 +94,7 @@ When taking volume snapshots, there are limitations:
9494
- Volume snapshots cannot be created for PVCs that are not provisioned by CSI drivers with [Volume Snapshots](https://kubernetes.io/docs/concepts/storage/volume-snapshots/) support.
9595
- Volume snapshots cannot be created for PVCs that are provisioned by CSI drivers that don't support [Volume Snapshots](https://kubernetes.io/docs/concepts/storage/volume-snapshots/).
9696
- When using host nodes:
97-
- Currently volume snapshots are created only for PersistentVolumeClaims that are synced to the vCluster host namespace. This means that, when the [Namespace sync](../../configure/vcluster-yaml/sync/to-host/advanced/namespaces) is enabled, volume snapshots are not created for the PersistentVolumeClaims that are synced to namespaces different than the vCluster host namespace.
97+
- Currently volume snapshots are created only for PersistentVolumeClaims that are synced to the vCluster host namespace. This means that, when the [Namespace sync](../../../configure/vcluster-yaml/sync/to-host/advanced/namespaces) is enabled, volume snapshots are not created for the PersistentVolumeClaims that are synced to namespaces different than the vCluster host namespace.
9898
- When using private nodes:
9999
- vCluster has to be deployed with `deploy.volumeSnapshotController.enabled` config set to `true`.
100100
- CSI driver that supports volume snapshots has to be installed in the virtual cluster.
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
title: AWS Providers
3+
sidebar_label: AWS Providers
4+
---
5+
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
import TenancySupport from '../../../_fragments/tenancy-support.mdx';
9+
import Mark from "@site/src/components/Mark";
10+
import InstallCli from '../../../_partials/deploy/install-cli.mdx';
11+
import KubeconfigUpdate from '@site/docs/_partials/kubeconfig_update.mdx';
12+
13+
This guide provides a step-by-step walkthrough of creating and restoring volume snapshots using AWS providers
14+
15+
## Prerequisites
16+
17+
- A prerequisite to complete this tutorial is to have an existing Amazon EKS cluster. Follow the [guide](../../../deploy/control-plane/container/environment/eks) to launch an EKS cluster with the EBS CSI Driver installed.
18+
- Based on the chosen tenancy model, follow the appropriate [steps](./#setup) to install the Kubernetes CSI snapshotter & required CRDs and for configuring the default VolumeSnapshotClass for each CSI driver.
19+
20+
## Create the virtual cluster
21+
22+
<details>
23+
<summary>
24+
vCluster with shared host cluster nodes
25+
</summary>
26+
Create a vCluster with default values by running the below command
27+
```bash
28+
vcluster create myvcluster
29+
```
30+
</details>
31+
32+
<details>
33+
<summary>
34+
vCluster with private nodes
35+
</summary>
36+
Create an EC2 instance and follow the documentation to join the instance as node in the vCluster and check if the node joined.
37+
38+
Create the vCluster by passing the below values
39+
```bash
40+
vcluster create myvcluster --values vcluster.yaml
41+
```
42+
```yaml title="vcluster.yaml"
43+
pro: true
44+
privateNodes:
45+
enabled: true
46+
autoUpgrade:
47+
imagePullPolicy: Never
48+
controlPlane:
49+
statefulSet:
50+
persistence:
51+
dataVolume:
52+
- name: data
53+
persistentVolumeClaim:
54+
claimName: ebs-claim
55+
service:
56+
spec:
57+
type: LoadBalancer
58+
networking:
59+
podCIDR: 10.64.0.0/16
60+
serviceCIDR: 10.128.0.0/16
61+
deploy:
62+
volumeSnapshotController:
63+
enabled: true
64+
```
65+
</details>
66+
67+
## Deploy a demo app inside the virtual cluster
68+
69+
Next, lets deploy a sample application into the vCluster. This app is writing the current date and time in five-second intervals to a file called out.txt.
70+
```bash
71+
cat <<EOF | kubectl apply -f -
72+
apiVersion: v1
73+
kind: PersistentVolumeClaim
74+
metadata:
75+
name: ebs-claim
76+
spec:
77+
accessModes:
78+
- ReadWriteOnce
79+
resources:
80+
requests:
81+
storage: 4Gi
82+
---
83+
apiVersion: v1
84+
kind: Pod
85+
metadata:
86+
name: app
87+
spec:
88+
containers:
89+
- name: app
90+
image: public.ecr.aws/amazonlinux/amazonlinux
91+
command: ["/bin/sh"]
92+
args: ["-c", "while true; do date -u >> /data/out.txt; sleep 5; done"]
93+
volumeMounts:
94+
- name: persistent-storage
95+
mountPath: /data
96+
volumes:
97+
- name: persistent-storage
98+
persistentVolumeClaim:
99+
claimName: ebs-claim
100+
EOF
101+
```
102+
Wait until the pod is running and the pvc is in `Bound` state.
103+
```bash
104+
❯ kubectl get pods
105+
NAME READY STATUS RESTARTS AGE
106+
app 1/1 Running 0 37s
107+
❯ kubectl get pvc
108+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
109+
ebs-claim Bound pvc-4062a395-e84e-4efd-91c4-8e09cb12d3a8 4Gi RWO <unset> 42s
110+
```
111+
112+
Run the command below and you can see the data being written on the persistent volume.
113+
```bash
114+
❯ kubectl exec -it app -- cat /data/out.txt | tail -n 3
115+
Tue Oct 28 13:38:41 UTC 2025
116+
Tue Oct 28 13:38:46 UTC 2025
117+
Tue Oct 28 13:38:51 UTC 2025
118+
```
119+
120+
121+
## Create snapshot with volumes
122+
123+
You can create a vCluster snapshot, with volume snapshots included, by using the `--include-volumes` param. vCluster CLI creates a snapshot request in the host cluster, which is then processed in the background by the vCluster snapshot controller, which will create volume snapshots.
124+
125+
Disconnect from the vCluster & then run the following command:
126+
127+
```bash
128+
vcluster snapshot create myvcluster "oci://ghcr.io/my-user/my-repo:my-tag" --include-volumes
129+
18:01:13 info Beginning snapshot creation... Check the snapshot status by running `vcluster snapshot get myvcluster oci://ghcr.io/my-user/my-repo:my-tag`
130+
```
131+
132+
You can check the snapshot creation progress with the following command:
133+
134+
```bash
135+
vcluster snapshot get myvcluster "oci://ghcr.io/my-user/my-repo:my-tag"
136+
137+
SNAPSHOT | VOLUMES | SAVED | STATUS | AGE
138+
-----------------------------------------+---------+-------+-----------+--------
139+
oci://ghcr.io/my-user/my-repo:my-tag | 1/1 | Yes | Completed | 2m51s
140+
141+
```
142+
143+
## Restore from the snapshot
144+
145+
We shall delete the app from the virtual cluster to simulate a data loss. Connect to the vCluster and run the below command:
146+
```bash
147+
cat <<EOF | kubectl delete -f -
148+
apiVersion: v1
149+
kind: PersistentVolumeClaim
150+
metadata:
151+
name: ebs-claim
152+
spec:
153+
accessModes:
154+
- ReadWriteOnce
155+
resources:
156+
requests:
157+
storage: 4Gi
158+
---
159+
apiVersion: v1
160+
kind: Pod
161+
metadata:
162+
name: app
163+
spec:
164+
containers:
165+
- name: app
166+
image: public.ecr.aws/amazonlinux/amazonlinux
167+
command: ["/bin/sh"]
168+
args: ["-c", "while true; do date -u >> /data/out.txt; sleep 5; done"]
169+
volumeMounts:
170+
- name: persistent-storage
171+
mountPath: /data
172+
volumes:
173+
- name: persistent-storage
174+
persistentVolumeClaim:
175+
claimName: ebs-claim
176+
EOF
177+
```
178+
179+
To restore the data, disconnect from the vCluster and then run the restore command with the `--restore-volumes` param. This creates a restore request which is then processed by the restore controller that orchestrates the restore of the PVC from the snapshots.
180+
181+
```bash
182+
vcluster restore myvcluster "oci://ghcr.io/my-user/my-repo:my-tag" --restore-volumes
183+
17:39:14 info Pausing vCluster myvcluster
184+
17:39:15 info Scale down statefulSet vcluster-myvcluster/myvcluster...
185+
17:39:17 info Starting snapshot pod for vCluster vcluster-myvcluster/myvcluster...
186+
...
187+
...
188+
2025-10-27 12:09:35 INFO snapshot/restoreclient.go:260 Successfully restored snapshot from oci://ghcr.io/my-user/my-repo:my-tag {"component": "vcluster"}
189+
17:39:37 info Resuming vCluster myvcluster after it was paused
190+
```
191+
192+
Once the vCluster is up and running, connect to it and verify the presence of the pod and pvc.
193+
```bash
194+
❯ kubectl get pods
195+
NAME READY STATUS RESTARTS AGE
196+
app 1/1 Running 0 12m
197+
❯ kubectl get pvc
198+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
199+
ebs-claim Bound pvc-c6ebf439-9fe5-4413-9f86-89916c1e4e49 4Gi RWO <unset> 12m
200+
```
201+
202+
Additionally, run the below command to confirm logs available from the previous run.
203+
```bash
204+
> kubectl exec -it app -- cat /data/out.txt
205+
...
206+
Tue Oct 28 13:39:21 UTC 2025
207+
Tue Oct 28 13:39:26 UTC 2025
208+
Tue Oct 28 13:39:31 UTC 2025
209+
Tue Oct 28 13:46:10 UTC 2025
210+
Tue Oct 28 13:46:15 UTC 2025
211+
Tue Oct 28 13:46:20 UTC 2025
212+
```

0 commit comments

Comments
 (0)