Local storage is the fastest disk on the platform, and it is where a production database belongs. Reads and writes go straight to the NVMe with no network in between. Local storage never replicates for you, so anything that must survive the loss of a server has to arrange that itself: run a database under an operator such as [CloudNativePG](https://cloudnative-pg.io/), which replicates across servers and backs itself up, or keep the data in [object storage](/docs/hetzner/apalla/storage/object/use-s3-from-workloads), where the S3 backend carries the redundancy. [Choose storage for a workload](/docs/hetzner/apalla/storage/choose-storage) covers when and why to run a database this way, and [Performance of local vs network storage](/docs/hetzner/apalla/storage/local/local-vs-network-performance) covers why it is fast. This page sets up the storage underneath. ## How a database uses local storage To the storage layer, a database is nothing special. The operator asks for a PersistentVolumeClaim on the `local-nvme` class, the same way any workload claims storage, and Kubernetes binds it to a logical volume on the server. Local just means the disk sits in the machine instead of across the network. CloudNativePG does not build on a StatefulSet. It manages the Postgres pods and their claims through its own controller, because a database needs decisions a StatefulSet cannot make from a pod's number alone: which instance is the primary, what order to update in, and on failover promoting the replica that is furthest ahead rather than the next one in order. Some operators do run on StatefulSets with Patroni. Either way, from the disk's point of view it is an ordinary PVC on `local-nvme`. TopoLVM is part of the Cluster Stack. Syself installs, configures, and upgrades it with the cluster, so there is no driver to install. Its node plugin runs on every bare metal worker, including tainted ones, and on no cloud node or control plane. Its controller scales with the bare metal workers: none while the cluster has no bare metal worker, then one per bare metal worker, up to two. > [!NOTE] > Local storage runs on bare metal servers, not on cloud nodes. The servers must not use RAID. If you installed TopoLVM yourself on an earlier release as the docs described, under the release name `csi-local` in `kube-system`, the upgrade to Kubernetes 1.37 migrates that install for you and keeps your volumes. An install under another release name or namespace is not migrated and conflicts with the built-in TopoLVM, so [remove it yourself](/docs/hetzner/apalla/storage/local/remove-a-self-installed-topolvm) right before you upgrade such a cluster, or afterward if you already upgraded. If your install used cert-manager, its Certificates, Issuers, and Secrets stay behind after the upgrade; nothing uses them, so you can delete them. While the driver switches over, mounted volumes keep working and new local volumes wait about 30 seconds. See [Upgrade the cluster to a new Kubernetes version](/docs/hetzner/apalla/clusters/upgrades/upgrade-to-a-new-kubernetes-version) for what to check before you upgrade. The [local storage classes](/docs/hetzner/apalla/storage/storage-classes-reference) exist on every cluster, alongside the built-in `standard` class: ```console $ kubectl get storageclasses NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE local-hdd topolvm.io Retain WaitForFirstConsumer true 10d local-nvme topolvm.io Retain WaitForFirstConsumer true 10d local-ssd topolvm.io Retain WaitForFirstConsumer true 10d standard (default) csi.hetzner.cloud Retain WaitForFirstConsumer true 10d ``` They serve no volume until you prepare the disks on a server. That is the one setup step, and you do it once per bare metal server, as part of bringing it online. ## What the platform configures Each class draws from one LVM volume group and its thin pool on the server. The names are fixed: | StorageClass | Device class | Volume group | Thin pool | | ------------ | ------------ | ------------ | ----------- | | `local-nvme` | `dc-nvme` | `vg-nvme` | `pool-nvme` | | `local-ssd` | `dc-ssd` | `vg-ssd` | `pool-ssd` | | `local-hdd` | `dc-hdd` | `vg-hdd` | `pool-hdd` | The Cluster Stack owns the device classes and the `local-*` StorageClasses. Create your volume groups and thin pools with exactly these names, and leave the classes as they are: StorageClass parameters cannot change in place, so a `local-*` class recreated with other parameters blocks the next Cluster Stack update until you delete it. When a bare metal server is reprovisioned, its claims stay bound. TopoLVM does not delete the PVCs of a node that leaves the cluster, so the volumes still on the data disks are there when the node comes back. See [Data survival across reprovision](/docs/hetzner/apalla/storage/local/data-survival-across-reprovision). TopoLVM can snapshot local volumes, but the Cluster Stack does not ship the VolumeSnapshot CRDs, a snapshot controller, or a VolumeSnapshotClass for `topolvm.io`. Install all three yourself if you want snapshots, and read [Volume snapshots and their limits](/docs/hetzner/apalla/storage/backup/snapshots-and-limits) first: a local snapshot stays on the same disk as its source. ## Prepare a server's disks, once per server Preparing the disks belongs with bringing a server into the cluster. When you [add a bare metal server](/docs/hetzner/apalla/servers-and-nodes/bare-metal/add-bare-metal-servers) you already pick its OS disk by WWN, and every other disk becomes a data disk. This step turns those data disks into the LVM volume groups TopoLVM serves. You do it once, when the server joins. Cluster upgrades and reprovisions leave the data disks alone, so you never repeat it for the same server. Run the commands on the server after it has joined the cluster. Open a root shell on it with a privileged debug pod, so you do not need SSH keys: ```console $ kubectl debug node/ -it --image=busybox --profile=sysadmin -- chroot /host ``` Direct SSH is a break-glass fallback, not the normal path. Find the data disks List the disks and separate the OS disk from the data disks: ```console $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme1n1 259:0 0 476.9G 0 disk `-nvme1n1p1 259:9 0 1M 0 part nvme0n1 259:1 0 476.9G 0 disk |-nvme0n1p1 259:2 0 512M 0 part /boot/efi |-nvme0n1p2 259:3 0 20G 0 part |-nvme0n1p3 259:4 0 512M 0 part |-nvme0n1p4 259:5 0 1M 0 part |-nvme0n1p5 259:6 0 448.9G 0 part /var |-nvme0n1p6 259:7 0 5G 0 part /var/log/journal | /var/syself `-nvme0n1p7 259:8 0 2G 0 part /var/log/audit ``` > [!CAUTION] > In the example above, `nvme0n1` is the OS disk, identified by its `/boot/efi` and `/var` mountpoints. Never create LVM on the OS disk, because that destroys the running system. Disk names differ between servers, so check the mountpoints on each one. NVMe, SSD, and HDD disks go in separate groups, so each type gets its own class. The default `lsblk` columns do not tell a spinning disk from a solid-state one, so add the `ROTA` column: `lsblk -d -o NAME,ROTA,SIZE,TYPE`. > [!TIP] > > - An NVMe disk has `nvme` at the start of its name. > - An HDD has `1` in the `ROTA` column. > - A SATA SSD has `0` in the `ROTA` column and no `nvme` prefix. Create the volume groups A freshly provisioned server has a 1 MiB BIOS boot partition on each blank data disk, so `pvcreate` refuses the whole disk with `device is partitioned`. Keep that partition, because the provisioner uses it for the boot loader. Set `DISK` to a data disk from the first step, and `LVM_PARTITION` to the second partition on it, which will hold LVM. On an NVMe disk that is `p2`, such as `/dev/nvme1n1p2`. On a SATA disk such as `sdb`, it is `/dev/sdb2`: ```console $ DISK=/dev/nvme1n1 $ LVM_PARTITION=/dev/nvme1n1p2 ``` Add an LVM partition after the boot partition: ```console $ echo ',,V' | sfdisk --append $DISK $ sfdisk --part-label $DISK 2 syself-local-storage $ partx -u $DISK ``` Create a physical volume on the new partition: ```console $ pvcreate $LVM_PARTITION ``` Create the volume group for the disk's type, one of `vg-nvme`, `vg-ssd`, or `vg-hdd`: ```console $ vgcreate vg-nvme $LVM_PARTITION ``` To add another disk to a group after setup, see [Local PV lifecycle](/docs/hetzner/apalla/storage/local/local-pv-lifecycle). Create a thin pool per group Once every disk is in a group, create one thin pool per group: ```console $ lvcreate --thinpool pool-nvme --extents 100%FREE vg-nvme ``` ```console $ lvcreate --thinpool pool-ssd --extents 100%FREE vg-ssd ``` ```console $ lvcreate --thinpool pool-hdd --extents 100%FREE vg-hdd ``` Confirm the capacity is visible TopoLVM reports each server's free capacity per disk type as a node annotation. Check that a prepared node advertises capacity: ```console $ kubectl get node -o jsonpath='{.metadata.annotations}' | tr ',' '\n' | grep capacity.topolvm.io ``` A node with a prepared NVMe group reports a non-zero value in `capacity.topolvm.io/dc-nvme`. A server that joined before you created its volume groups does not report them yet. Restart that node's `topolvm-node` pod so it rescans the groups: ```console $ kubectl -n kube-system delete pod -l app.kubernetes.io/name=topolvm,app.kubernetes.io/component=node --field-selector spec.nodeName= ``` ## Use the classes To pick which class fits which workload, and so which disks to prepare, see [Performance of local vs network storage](/docs/hetzner/apalla/storage/local/local-vs-network-performance#benchmark-with-your-real-access-pattern). Point a PVC at `local-nvme`, `local-ssd`, or `local-hdd` like any other class. A claim for a disk type the server does not have stays Pending, because the server has no matching volume group. ```yaml title="pv-claim.yaml" apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv-claim spec: storageClassName: local-nvme accessModes: - ReadWriteOnce resources: requests: storage: 10Gi ``` A local volume is ReadWriteOnce and stays on the server it was created on. Because the volume cannot move, the pod that uses it must schedule to that same server. If the server is full or gone, the pod stays Pending. The volume carries no redundancy of its own, so give it an off-server backup first, and application-level replication on top. To keep a lost or decommissioned disk from giving up its data, encrypt it at rest: [Encrypt data at rest with LUKS](/docs/hetzner/apalla/storage/operations/encrypt-data-at-rest) layers LUKS under these same volume groups. ## Label dedicated storage hosts If you dedicate bare-metal hosts to storage, label them and make your bare-metal pools select them, as [Add bare-metal servers](/docs/hetzner/apalla/servers-and-nodes/bare-metal/add-bare-metal-servers) describes. An unlabeled host is free for any pool to claim, including another cluster picking up capacity during an upgrade, and whoever claims it gets the server with its local disks and data. Related: [Encrypt data at rest with LUKS](/docs/hetzner/apalla/storage/operations/encrypt-data-at-rest), [Performance of local vs network storage](/docs/hetzner/apalla/storage/local/local-vs-network-performance), and [Local PV lifecycle](/docs/hetzner/apalla/storage/local/local-pv-lifecycle).