Took myself ages to figure this out, so I am noting this down for my future self.
Just a note – this is not the indented workflow, but rather a “getting started with kubernetes” step.
First, we need to add NFS as a storage class:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: managed-nfs-storage
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
archiveOnDelete: "false"
Then, we can add the actual storage:
kind: PersistentVolume
apiVersion: v1
metadata:
name: nfs-persistentvolume
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
storageClassName: "nfs" # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name
nfs:
path: "/path/to/share"
server: "xxx.xxx.xxx.xxx"
readOnly: false
claimRef:
name: nfs-persistentvolumeclaim
namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-persistentvolumeclaim
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
storageClassName: "nfs" # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name
volumeName: nfs-persistentvolume
Hope this helps
Bonus – run a Minecraft Bedrock inside K8S using your newly created PVC as storage