Minikube不尊重Persistent Volumes

时间:2017-06-05 13:35:36

标签: kubernetes nfs minikube

我正在尝试使用minikube为MariaDB设置一些持久的NFS卷。每次加载声明配置时,minikube都会创建默认持久卷,而不是使用我通过NFS提供的卷。我无法解释为什么会这样做......

mariadb-nfs-volume.yaml文件显示为:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.3.121
    path: "/var/nfsshare"
    readOnly: false

mariadb-pv-claim.yaml文件显示为:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mariadb-pv-claim
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 3Gi

还有一些调试:

; 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

2 个答案:

答案 0 :(得分:2)

也许有点晚了,但至少对于这里的记录来说是一个答案:

创建PersistentVolume时给它storageClassName(我在这里使用 mariadab-nfs ):

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

并声明该卷时,请指定相同的storageClassName:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mariadb-pv-claim
spec:
  storageClassName: mariadb-nfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 3Gi

然后Kubernetes将使用定义的pv作为pvc,无需禁用minikube动态配置。

答案 1 :(得分:0)

minikube默认启用动态存储配置。您可以尝试禁用它,以便NFS PV支持您的声明。

minikube start --feature-gates=DynamicVolumeProvisioning=false