I am trying to set up MariaDB with some persistent NFS volume using minikube. Every time I load the claim configuration, minikube creates a default persistent volumes instead of using the one I provide via NFS. I cannot work out why it does that…
The mariadb-nfs-volume.yaml
file reads:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.3.121
path: "/var/nfsshare"
readOnly: false
And the mariadb-pv-claim.yaml
file reads:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mariadb-pv-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
And some debug:
; kubectl get pv nfs
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM STORAGECLASS REASON AGE
nfs 10Gi RWX Retain Available 56m
; kubectl get pvc mariadb-pv-claim
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE
mariadb-pv-claim Bound pvc-7f20f205-49f2-11e7-83ab-525400dd1f77 3Gi RWX standard 56m
minikube has dynamic storage provisioning turned on by default. You can try to disable it so that your claim is met by your NFS PV.
minikube start --feature-gates=DynamicVolumeProvisioning=false
maybe a little late, but at least for the records here's an answer:
When creating the PersistentVolume
give it a storageClassName
(I use mariadab-nfs here):
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
storageClassName: mariadb-nfs
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.3.121
path: "/var/nfsshare"
readOnly: false
and when claiming that volume, specify that very same storageClassName:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mariadb-pv-claim
spec:
storageClassName: mariadb-nfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
Kubernetes then will use the defined pv for the pvc, no need to disable the minikube dynamic provisioning.