簡體   English   中英

如何在Kubernetes中直接掛載外部NFS共享/卷(1.10.3)

[英]How to directly mount external NFS share/volume in kubernetes(1.10.3)

我正在使用kubernetes:v1.10.3,我有一台外部NFS服務器,可以將其安裝在任何地方(任何物理機器)。 我想將此NFS直接安裝到pod / container。 我嘗試過,但每次遇到錯誤時。 不想使用特權,請幫助我修復。

錯誤:卷“ nfs”的MountVolume.SetUp失敗:裝載失敗:退出狀態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 / volume / kubernetes.io〜nfs / nfs輸出:運行范圍作為單元run-43393.scope。 掛載:錯誤的fs類型,錯誤的選項,在10.225.241.137:/stagingfs/alt/上錯誤的超級塊,缺少的代碼頁或幫助程序或其他錯誤(對於多個文件系統(例如nfs,cif),您可能需要/ 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."
      }
    ]
  }
}

問候阿努帕姆·納拉揚

如錯誤日志中所述:

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

根據這個問題 ,您可能會缺少可以使用sudo apt install nfs-common安裝的nfs-commons軟件包。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM