Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: how to import volumes #860

Merged
merged 7 commits into from
Jan 28, 2025
59 changes: 59 additions & 0 deletions docs/kubernetes/how-to-import-volumes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# How to import volumes

This guide explains how to import an existing Hetzner Volume into your Kubernetes cluster with the csi-driver installed.

1. Detach your volume by running

```bash
hcloud volume detach <VOLUME-NAME>
```

2. Find the ID of your volume by running

```bash
hcloud volume describe <VOLUME-NAME>
```

3. Create a new PersistentVolume and insert the volume ID into the `<VOLUME-ID>` and your volume location into `<VOLUME-LOCATION>`. This ensures that the topology constraints are set up correctly.

```yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: imported-data
spec:
storageClassName: hcloud-volumes
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
csi:
fsType: ext4
driver: csi.hetzner.cloud
volumeHandle: "<VOLUME-ID>"
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: csi.hetzner.cloud/location
operator: In
values:
- <VOLUME-LOCATION>
```

4. Create a new PersistentVolumeClaim and link it to the PersistentVolume via `volumeName`

```yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: imported-data
spec:
storageClassName: hcloud-volumes
volumeName: imported-data # <-- reference PV name
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
```
Loading