【问题标题】:How to create an kubernetes NFS volume on Google Container Engine如何在 Google Container Engine 上创建 kubernetes NFS 卷
【发布时间】:2017-09-07 14:37:58
【问题描述】:

我正在尝试在 Google Container Engine (GKE) 上创建一个 kubernetes NFS 卷并让它被部署使用。

我在这个 github 存储库kubernetes-nfs-volume-on-gke 中显示了几个步骤:

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

经过这一步,得到的错误是这样的:

$ 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的dashboard中,报错如下:

无法为 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。我可以在几周内回答这个问题。
  • 感谢您的建议...我仍在努力...如果找到解决方案,我将在此处发布...如果您想进行 PR kubernetes-nfs-volume-on-gke 它将是太棒了!

标签: kubernetes nfs google-kubernetes-engine persistent-volumes persistent-volume-claims


【解决方案1】:

kubernetes 上 issue 中的 comment 似乎解决了 GKE 上的这个 NFS 问题。

引用该评论:

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

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

还有其他问题可以跟踪here 和here。

【讨论】:

    猜你喜欢
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    • 2016-06-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 2018-09-19
    相关资源
    最近更新 更多