Kubernetes NFS卷装载失败,退出状态为32

bxjv4tth  于 2022-12-29  发布在  Kubernetes
关注(0)|答案(7)|浏览(280)

我在Ubuntu机器上安装了Kubernetes安装程序,我正在尝试安装一个nfs卷,并根据http://kubernetes.io/v1.1/examples/nfs/文档将其挂载到容器中。
nfs服务和pod配置

kind: Service
apiVersion: v1
metadata:
  name: nfs-server
spec:
  ports:
    - port: 2049
  selector:
    role: nfs-server
---
apiVersion: v1
kind: Pod
metadata:
  name: nfs-server
  labels:
    role: nfs-server
spec:
  containers:
    - name: nfs-server
      image: jsafrane/nfs-data
      ports:
        - name: nfs
          containerPort: 2049
      securityContext:
        privileged: true

pod配置以安装nfs卷

apiVersion: v1
kind: Pod
metadata:
  name: nfs-web
spec:
  containers:
    - name: web
      image: nginx
      ports:
        - name: web
          containerPort: 80
      volumeMounts:
          # name must match the volume name below
          - name: nfs
            mountPath: "/usr/share/nginx/html"
  volumes:
    - name: nfs
      nfs:
        # FIXME: use the right hostname
        server: 192.168.3.201
        path: "/"

当我运行kubectl describe nfs-web的时候,我得到了下面的输出,提到它无法挂载nfs卷。这可能是什么原因?

Name:               nfs-web
Namespace:          default
Image(s):           nginx
Node:               192.168.1.114/192.168.1.114
Start Time:         Sun, 06 Dec 2015 08:31:06 +0530
Labels:             <none>
Status:             Pending
Reason:             
Message:            
IP:             
Replication Controllers:    <none>
Containers:
  web:
    Container ID:   
    Image:      nginx
    Image ID:       
    State:      Waiting
      Reason:       ContainerCreating
    Ready:      False
    Restart Count:  0
    Environment Variables:
Conditions:
  Type      Status
  Ready     False 
Volumes:
  nfs:
    Type:   NFS (an NFS mount that lasts the lifetime of a pod)
    Server: 192.168.3.201
    Path:   /
    ReadOnly:   false
  default-token-nh698:
    Type:   Secret (a secret that should populate this volume)
    SecretName: default-token-nh698
Events:
  FirstSeen LastSeen    Count   From            SubobjectPath   Reason      Message
  ───────── ────────    ─────   ────            ─────────────   ──────      ───────
  36s       36s     1   {scheduler }                Scheduled   Successfully assigned nfs-web to 192.168.1.114
  36s       2s      5   {kubelet 192.168.1.114}         FailedMount Unable to mount volumes for pod "nfs-web_default": exit status 32
  36s       2s      5   {kubelet 192.168.1.114}         FailedSync  Error syncing pod, skipping: exit status 32
insrf1ej

insrf1ej1#

我遇到了同样的问题,我通过在每个Kubernetes节点中安装nfs-common解决了这个问题。

apt-get install -y nfs-common

我的节点安装时未安装nfs-common。Kubernetes将要求每个节点将NFS装载到可供Pod使用的特定目录中。由于找不到 mount.nfs,装载过程失败。
祝你好运!

dddzy1tm

dddzy1tm2#

似乎客户端上的volumes.nfs.server= 192.168.3.201配置不正确。应将其设置为nfs-server服务的ClusterIP地址。

20jt8wwn

20jt8wwn3#

NFS也有同样的问题,只允许根装载。修复方法:
a.允许非root用户挂载NFS(在服务器上)。

B.在持久卷添加中

mountOptions:
    - nfsvers=4.1
aoyhnmkz

aoyhnmkz4#

我通过在工作节点上安装nfs-utils修复了这个问题。

bybem2ql

bybem2ql5#

在我的例子中,问题是我没有在/etc/exports文件中声明nfs的主机服务器,在那里添加了主机服务器的条目后,卷工作正常。
如果你修改文件在无论如何然后你需要重新启动服务太;

sudo systemctl restart nfs-kernel-server

/etc/exports文件中的条目示例;

/var/nfs/home   192.111.222.333(rw,sync,no_subtree_check)
gt0wga4j

gt0wga4j6#

在我的案例中,问题是在卷hostPath中定义的文件夹未在本地创建。在工作节点服务器中创建文件夹后,问题得到解决。

Warning  FailedMount  3m18s                 kubelet            Unable to attach or mount volumes: unmounted volumes=[temp-volume], unattached volumes=[nfsvol-vre-data temp1-volume consumer1-serviceaccount-token-sdfsdf nfsvol]: timed out waiting for the condition
  Warning  FailedMount  71s (x10 over 5m20s)  kubelet            MountVolume.SetUp failed for volume "temp-volume" : hostPath type check failed: /tmp/folder is not a directory
  Warning  FailedMount  63s                   kubelet            Unable to attach or mount volumes: unmounted volumes=[temp-volume], unattached volumes=[nfsvol nfsvol-vre-data temp1-volume consumer1-serviceaccount-token-sdfsdf]: timed out waiting for the condition
jdgnovmf

jdgnovmf7#

您需要在每个主节点和节点上执行以下操作

sudo yum install nfs-utils -y

相关问题