This is a Container Storage Interface driver for Hetzner Cloud enabling you to use Volumes within Kubernetes. Please note that this driver requires Kubernetes 1.13 or newer.
-
Make sure that the following feature gates are enabled in your cluster (kubelet and kube-apiserver):
--feature-gates=CSINodeInfo=true,CSIDriverRegistry=true
Also make sure that privileged pods are allowed in your cluster (kubelet and kube-apiserver):
--allow-privileged=true
See Enabling features and Enable privileged Pods in the Kubernetes CSI documentation.
-
Create the
CSINodeInfo
resource:kubectl create -f https://raw.githubusercontent.com/kubernetes/csi-api/master/pkg/crd/manifests/csinodeinfo.yaml
See Enabling CSINodeInfo in the Kubernetes CSI documentation.
-
Create an API token in the Hetzner Cloud Console.
-
Create a secret containing the token:
apiVersion: v1 kind: Secret metadata: name: hcloud-csi namespace: kube-system stringData: token: YOURTOKEN
-
Deploy the CSI driver and wait until everything is up and running:
kubectl apply -f https://raw.githubusercontent.com/hetznercloud/csi-driver/master/deploy/kubernetes/hcloud-csi.yml
-
To verify everything is working, create a persistent volume claim and a pod which uses that volume:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: csi-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: hcloud-volumes --- kind: Pod apiVersion: v1 metadata: name: my-csi-app spec: containers: - name: my-frontend image: busybox volumeMounts: - mountPath: "/data" name: my-csi-volume command: [ "sleep", "1000000" ] volumes: - name: my-csi-volume persistentVolumeClaim: claimName: csi-pvc
Once the pod is ready, exec a shell and check that your volume is mounted at
/data
.
MIT license