From 5cc7e84b5aa15da635b7f1ef1ea68fc3a620e04a Mon Sep 17 00:00:00 2001
From: Lukas Metzner <lukas.metzner@hetzner-cloud.de>
Date: Tue, 28 Jan 2025 09:40:49 +0100
Subject: [PATCH] docs: how to import volumes (#860)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Julian Tölle <julian.toelle@hetzner-cloud.de>
Co-authored-by: Jonas L. <jooola@users.noreply.github.com>
---
 docs/kubernetes/how-to-import-volumes.md | 59 ++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 docs/kubernetes/how-to-import-volumes.md

diff --git a/docs/kubernetes/how-to-import-volumes.md b/docs/kubernetes/how-to-import-volumes.md
new file mode 100644
index 0000000..d0ec542
--- /dev/null
+++ b/docs/kubernetes/how-to-import-volumes.md
@@ -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
+```
-- 
GitLab