如何在Google容器引擎上创建一个Kubernetes NFS卷

4

我正在尝试在Google容器引擎(GKE)上创建一个Kubernetes NFS卷,并使其被部署使用。

我按照这个Github仓库kubernetes-nfs-volume-on-gke中所示的步骤进行:

  1. 创建GKE集群和GCE持久磁盘
  2. 配置kubectl的上下文以处理GKE集群
  3. 创建持久卷(PV)和持久卷声明(PVC)
  4. 创建NFS服务器
  5. 为NFS服务器创建服务以公开它(该服务的IP地址用于创建NFS PV和NFS PVC)
  6. 创建NFS卷
  7. 创建busybox部署以检查是否可以访问NFS卷。

按照这些步骤后,出现了以下错误:

$ kubectl describe pods  nfs-busybox-2762569073-lhb5p
Name:       nfs-busybox-2762569073-lhb5p
Namespace:  default
Node:       gke-mappedinn-cluster-default-pool-f94cb0d4-fmfb/10.240.0.3
Start Time: Wed, 12 Apr 2017 04:12:20 +0400
Labels:     name=nfs-busybox
        pod-template-hash=2762569073
Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"nfs-busybox-2762569073","uid":"b1e523ae-1f14-11e7-a084-42010a8e0...
        kubernetes.io/limit-ranger=LimitRanger plugin set: cpu request for container busybox
Status:     Pending
IP:     
Controllers:    ReplicaSet/nfs-busybox-2762569073
Containers:
  busybox:
    Container ID:
    Image:      busybox
    Image ID:       
    Port:       
    Command:
      sh
      -c
      while true; do date > /mnt/index.html; hostname >> /mnt/index.html; sleep $(($RANDOM % 5 + 5)); done
    State:      Waiting
      Reason:       ContainerCreating
    Ready:      False
    Restart Count:  0
    Requests:
      cpu:      100m
    Environment:    <none>
    Mounts:
      /mnt from my-pvc-nfs (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-20n4b (ro)
Conditions:
  Type      Status
  Initialized   True
  Ready     False
  PodScheduled  True
Volumes:
  my-pvc-nfs:
    Type:   PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  nfs
    ReadOnly:   false
  default-token-20n4b:
    Type:   Secret (a volume populated by a Secret)
    SecretName: default-token-20n4b
    Optional:   false
QoS Class:  Burstable
Node-Selectors: <none>
Tolerations:    <none>
Events:
  FirstSeen LastSeen    Count   From                                SubObjectPath   Type        Reason      Message
  --------- --------    -----   ----                                -------------   --------    ------      -------
  5m        5m      1   default-scheduler                               Normal      Scheduled   Successfully assigned nfs-busybox-2762569073-lhb5p to gke-mappedinn-cluster-default-pool-f94cb0d4-fmfb
  3m        48s     2   kubelet, gke-mappedinn-cluster-default-pool-f94cb0d4-fmfb           Warning     FailedMount Unable to mount volumes for pod "nfs-busybox-2762569073-lhb5p_default(b1e7c901-1f14-11e7-a084-42010a8e0116)": timeout expired waiting for volumes to attach/mount for pod "default"/"nfs-busybox-2762569073-lhb5p". list of unattached/unmounted volumes=[my-pvc-nfs]
  3m        48s     2   kubelet, gke-mappedinn-cluster-default-pool-f94cb0d4-fmfb           Warning     FailedSync  Error syncing pod, skipping: timeout expired waiting for volumes to attach/mount for pod "default"/"nfs-busybox-2762569073-lhb5p". list of unattached/unmounted volumes=[my-pvc-nfs]
  37s       37s     1   kubelet, gke-mappedinn-cluster-default-pool-f94cb0d4-fmfb           Warning     FailedMount MountVolume.SetUp failed for volume "kubernetes.io/nfs/b1e7c901-1f14-11e7-a084-42010a8e0116-nfs" (spec.Name: "nfs") pod "b1e7c901-1f14-11e7-a084-42010a8e0116" (UID: "b1e7c901-1f14-11e7-a084-42010a8e0116") with: mount failed: exit status 32
Mounting command: /home/kubernetes/bin/mounter
Mounting arguments: 10.247.250.208:/exports /var/lib/kubelet/pods/b1e7c901-1f14-11e7-a084-42010a8e0116/volumes/kubernetes.io~nfs/nfs nfs []
Output: Running mount using a rkt fly container
run: group "rkt" not found, will use default gid when rendering images 

在 Kubernetes 仪表板中,错误如下所示:

无法为 pod "nfs-busybox-2762569073-lhb5p_default(b1e7c901-1f14-11e7-a084-42010a8e0116)" 挂载卷:超时等待卷附加/挂载到 pod "default"/"nfs-busybox-2762569073-lhb5p"。未附加/未挂载的卷列表=[my-pvc-nfs]

同步 pod 出错,跳过:超时等待卷附加/挂载到 pod "default"/"nfs-busybox-2762569073-lhb5p"。未附加/未挂载的卷列表=[my-pvc-nfs]

我有什么遗漏吗?

谢谢,


我计划最近编写一份关于在GKE上编写NFS教程的指南。我现在不知道答案,但感谢你提出这个问题,因为它证实了需要这样一个教程。如果你想保持联系,我的电子邮件是ahmetb✳︎google.com。我可以在几周内回答这个问题。 - ahmet alp balkan
感谢您的提议...我仍在努力中...如果我找到了解决方案,我会在这里发布...如果您想要提交PR kubernetes-nfs-volume-on-gke,那就太好了! - Amine Jallouli
1个回答

2
这个评论在kubernetes的问题中似乎解决了GKE上的NFS问题。
引用该评论:

编辑examples/volumes/nfs/nfs-pv.yaml将最后一行更改为path:"/"

编辑examples/volumes/nfs/nfs-server-rc.yaml将镜像更改为启用了NFSv4镜像:gcr.io/google_containers/volume-nfs:0.8

此外,还有其他问题跟踪这里这里

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接