【问题标题】:How to directly mount external NFS share/volume in kubernetes(1.10.3)如何在 kubernetes(1.10.3) 中直接挂载外部 NFS 共享/卷
【发布时间】:2018-11-14 23:21:37
【问题描述】:

我正在使用 kubernetes:v1.10.3,我有一个外部 NFS 服务器,我可以安装在任何地方(任何物理机)。我想将此 NFS 直接挂载到 pod/container 。我试过了,但每次我都出错。不想使用权限,请帮我解决。

错误:卷“nfs”的 MountVolume.SetUp 失败:安装失败:退出 status 32 挂载命令:systemd-run 挂载参数: --description=Kubernetes 临时挂载 /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs --scope -- mount -t nfs 10.225.241.137:/stagingfs/alt/ /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs 输出:以单位 run-43393.scope 运行范围。 mount:错误的 fs 类型, 错误选项,10.225.241.137:/stagingfs/alt/ 上的错误超级块,丢失 代码页或帮助程序,或其他错误(对于多个文件系统 (例如 nfs、cifs)您可能需要 /sbin/mount。辅助程序) 在某些情况下,可以在 syslog 中找到有用的信息 - 尝试 dmesg |尾巴左右。

NFS server :  mount -t nfs 10.X.X.137:/stagingfs/alt   /alt    

我在这里为音量添加了两件事,但每次都会出错。

第一:

"volumeMounts": [
          {
            "name": "nfs",
            "mountPath": "/alt"
          }

        ],

第二:

 "volumes": [
  {
    "name": "nfs",
    "nfs": {
      "server": "10.X.X.137",
      "path": "/stagingfs/alt/"
    }
  }

],

----------完成 yaml ------------------------ --------

{
  "kind": "Deployment",
  "apiVersion": "extensions/v1beta1",
  "metadata": {
    "name": "jboss",
    "namespace": "staging",
    "selfLink": "/apis/extensions/v1beta1/namespaces/staging/deployments/jboss",
    "uid": "6a85e235-68b4-11e8-8181-00163eeb9788",
    "resourceVersion": "609891",
    "generation": 2,
    "creationTimestamp": "2018-06-05T11:34:32Z",
    "labels": {
      "k8s-app": "jboss"
    },
    "annotations": {
      "deployment.kubernetes.io/revision": "2"
    }
  },
  "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "k8s-app": "jboss"
      }
    },
    "template": {
      "metadata": {
        "name": "jboss",
        "creationTimestamp": null,
        "labels": {
          "k8s-app": "jboss"
        }
      },
      "spec": {
          "volumes": [
      {
        "name": "nfs",
        "nfs": {
          "server": "10.X.X.137",
          "path": "/stagingfs/alt/"
        }
      }

    ],
        "containers": [
          {
            "name": "jboss",
            "image": "my.abc.com/alt:7.1_1.1",
            "resources": {},
            "volumeMounts": [
          {
            "name": "nfs",
            "mountPath": "/alt"
          }

        ],
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "IfNotPresent",
            "securityContext": {
              "privileged": true
            }
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "securityContext": {},
        "schedulerName": "default-scheduler"
      }
    },
    "strategy": {
      "type": "RollingUpdate",
      "rollingUpdate": {
        "maxUnavailable": "25%",
        "maxSurge": "25%"
      }
    },
    "revisionHistoryLimit": 10,
    "progressDeadlineSeconds": 600
  },
  "status": {
    "observedGeneration": 2,
    "replicas": 1,
    "updatedReplicas": 1,
    "readyReplicas": 1,
    "availableReplicas": 1,
    "conditions": [
      {
        "type": "Available",
        "status": "True",
        "lastUpdateTime": "2018-06-05T11:35:45Z",
        "lastTransitionTime": "2018-06-05T11:35:45Z",
        "reason": "MinimumReplicasAvailable",
        "message": "Deployment has minimum availability."
      },
      {
        "type": "Progressing",
        "status": "True",
        "lastUpdateTime": "2018-06-05T11:35:46Z",
        "lastTransitionTime": "2018-06-05T11:34:32Z",
        "reason": "NewReplicaSetAvailable",
        "message": "ReplicaSet \"jboss-8674444985\" has successfully progressed."
      }
    ]
  }
}

问候 阿努帕姆·纳拉扬

【问题讨论】:

标签: docker kubernetes


【解决方案1】:

如错误日志中所述:

for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program

根据这个question,您可能缺少可以使用sudo apt install nfs-common 安装的nfs-commons 包

【讨论】:

  • 嗨,即使在 Dokerfile RUN yum install -y nfs-utils nfs-common rpcbind nfslock 上安装了 utills 和 common 后,我仍然遇到同样的错误
  • @Anupam 需要在节点上完成安装
猜你喜欢
  • 1970-01-01
  • 2017-12-30
  • 2018-08-22
  • 1970-01-01
  • 2021-05-03
  • 2021-10-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多