我有以下持久量和音量声明:
kind: PersistentVolume
apiVersion: v1
metadata:
name: kloud
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
nfs:
server: 172.21.51.42
path: /
readOnly: false
和
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: kloud
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
nfs服务器是AWS EFS。我特意ssh到k8s master并检查我可以手动挂载NFS卷。但是,当我使用kubectl创建卷和声明时,它无限期地悬挂在那里等待:
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE
kloud Pending gp2 8s
如果我将模式更改为ReadWriteOnce
,它会按预期工作,不会挂起。
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESSMODES STORAGECLASS AGE
kloud Bound pvc-c9a01bff-94d0-11e7-8ed4-0aec4a0f734a 100Gi RWO gp2
我有遗漏的东西吗?如何使用k8s和EFS创建RWX声明?
答案 0 :(得分:10)
您需要在群集中设置EFS配置程序。默认的Kubernetes发行版仍然不支持挂载EFS,因此您需要此扩展名:https://github.com/kubernetes-incubator/external-storage/tree/master/aws/efs
您需要设置它的存储类:
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: aws-efs
provisioner: example.com/aws-efs
然后写下类型的PVC:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: efs
annotations:
volume.beta.kubernetes.io/storage-class: "aws-efs"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
不要介意存储空间大小,虽然它没有被EFS使用,但Kubernetes要求你在那里设置一些东西才能工作。