我试图挂载NFS卷到我的豆荚,但没有成功。
我有一台运行nfs挂载点的服务器,当我尝试从其他运行的服务器连接到它时
sudo mount -t nfs -o proto=tcp,port=2049 10.0.0.4:/export /mnt
工作正常
另外值得一提的是,当我从部署中删除卷并且该容器正在运行时。 我login到它,我可以Telnet到端口111和2049 10.0.0.4成功。 所以真的似乎没有任何沟通问题
以及:
showmount -e 10.0.0.4 Export list for 10.0.0.4: /export/drive 10.0.0.0/16 /export 10.0.0.0/16
所以我可以假设服务器和客户端之间没有networking或configuration问题(我正在使用亚马逊和我testing的服务器与k8s minions在同一个安全组中)
PS:服务器是一个简单的ubuntu-> 50GB的磁盘
Kubernetes v1.3.4
所以我开始创build我的PV
apiVersion: v1 kind: PersistentVolume metadata: name: nfs spec: capacity: storage: 50Gi accessModes: - ReadWriteMany nfs: server: 10.0.0.4 path: "/export"
和我的PVC
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nfs-claim spec: accessModes: - ReadWriteMany resources: requests: storage: 50Gi
这里是kubectl如何描述他们:
Name: nfs Labels: <none> Status: Bound Claim: default/nfs-claim Reclaim Policy: Retain Access Modes: RWX Capacity: 50Gi Message: Source: Type: NFS (an NFS mount that lasts the lifetime of a pod) Server: 10.0.0.4 Path: /export ReadOnly: false No events.
和
Name: nfs-claim Namespace: default Status: Bound Volume: nfs Labels: <none> Capacity: 0 Access Modes: No events.
荚部署:
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: mypod labels: name: mypod spec: replicas: 1 strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 0 type: RollingUpdate template: metadata: name: mypod labels: # Important: these labels need to match the selector above, the api server enforces this constraint name: mypod spec: containers: - name: abcd image: irrelevant to the question ports: - containerPort: 80 env: - name: hello value: world volumeMounts: - mountPath: "/mnt" name: nfs volumes: - name: nfs persistentVolumeClaim: claimName: nfs-claim
当我部署我的POD时,我得到以下内容:
Volumes: nfs: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: nfs-claim ReadOnly: false default-token-6pd57: Type: Secret (a volume populated by a Secret) SecretName: default-token-6pd57 QoS Tier: BestEffort Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 13m 13m 1 {default-scheduler } Normal Scheduled Successfully assigned xxx-2140451452-hjeki to ip-10-0-0-157.us-west-2.compute.internal 11m 7s 6 {kubelet ip-10-0-0-157.us-west-2.compute.internal} Warning FailedMount Unable to mount volumes for pod "xxx-2140451452-hjeki_default(93ca148d-6475-11e6-9c49-065c8a90faf1)": timeout expired waiting for volumes to attach/mount for pod "xxx-2140451452-hjeki"/"default". list of unattached/unmounted volumes=[nfs] 11m 7s 6 {kubelet ip-10-0-0-157.us-west-2.compute.internal} Warning FailedSync Error syncing pod, skipping: timeout expired waiting for volumes to attach/mount for pod "xxx-2140451452-hjeki"/"default". list of unattached/unmounted volumes=[nfs]
尝试了我所知道的一切,以及我所能想到的一切。 我在这里失踪或做错了什么?
我测试了Kubernetes版本1.3.4和1.3.5,而NFS装载对我没有任何作用。 后来我切换到1.2.5,该版本给了我更详细的信息(kubectl描述pod …)。 事实证明,在超级映像镜像中缺少'nfs-common'。 在基于主节点和工作节点上的hyperkube映像的所有容器实例中添加nfs-common后,NFS共享开始正常工作(挂载成功)。 这就是这种情况。 我在实践中测试了它,并解决了我的问题。