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:
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.
Network Observability with Hubble
Learn how to use Hubble to observe network traffic, troubleshoot connectivity issues, and understand service communication in Kubernetes.
Using local storage in bare metal
Configure Hetzner bare metal servers to use their local storage for high-performance databases.