Using HCloud storage

Introduction

Clusters created with Syself Autopilot comes with the CSI driver for hcloud working out-of-the-box. A Storage Class is available in your cluster, exposing the underlying Hetzner storage to be used by your workload.

In this guide, you'll see an example application making use of Hetzner volumes.

Using the Storage Class

A Storage Class called standard is present in your workload cluster. This is the Storage Class you should use if you want to store data in Hetzner volumes.

note

The standard storage class can only be used in hcloud nodes. Pods requesting storage from this class in bare metal nodes will not start.

Below you can find an example manifest showing how to create a Persistent Volume using the standard Storage Class and bind it to a pod using a Persistent Volume Claim:

storagetest.yaml yaml
apiVersion: v1 kind: PersistentVolume metadata: name: pv-volume labels: type: local spec: storageClassName: standard capacity: storage: 2Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data" --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pv-claim spec: storageClassName: standard accessModes: - ReadWriteOnce resources: requests: storage: 1Gi --- apiVersion: v1 kind: Pod metadata: name: pv-pod spec: volumes: - name: pv-storage persistentVolumeClaim: claimName: pv-claim containers: - name: pv-container image: nginx ports: - containerPort: 80 name: "http-server" volumeMounts: - mountPath: "/usr/share/nginx/html" name: pv-storage affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: instance.hetzner.cloud/is-root-server operator: NotIn values: - "true"

Now any data stored under /usr/share/nginx/html inside the pv-container will be persisted.

note

Currently, ReadWriteMany volumes are not supported by Hetzner CSI. This means you can't mount volumes with read and write permissions by many nodes.

You can still share a ReadWriteOnce volume between multiple pods, but it's required that all of them be on the same node. This could be achieved by setting a node affinity.

Next
Introduction to Syself Autopilot