k8s - nfs 绑定的pod一直处于ContainerCreating状态

目录

centos查看是否安装了nfs

volume.yaml

pod绑定pvc

pod绑定了pvc后,一直处于ContainerCreating状态

describe pod看到报错说挂载失败

查看nfs的共享目录 

配置nfs共享目录

更新volume.yaml

节点安装apt-get install nfs-common



centos查看是否安装了nfs

[root@storage00 ~]# rpm -qa | grep nfs
libnfsidmap-0.25-19.el7.x86_64
nfs-utils-1.3.0-0.65.el7.x86_64
[root@storage00 ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-48.el7.x86_64

volume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: vmstorage
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    server: 10.10.13.23
    path: /data/storage
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: vmstorage
  namespace: monitoring
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

pod绑定pvc

...
          volumeMounts:
            - name: vmstorage-volume
              mountPath: /data/vmstorage
              readOnly: false
      volumes:
      - name: vmstorage-volume
        persistentVolumeClaim:
          claimName: vmstorage         
...

pod绑定了pvc后,一直处于ContainerCreating状态

root@m1:~/katy/monitoring/vm# kubectl get po -n monitoring
NAME                                   READY   STATUS              RESTARTS   AGE
vmstorage-0                            0/1     ContainerCreating   0          2m21s

describe pod看到报错说挂载失败

查看nfs的共享目录 

发现并没有配置过nfs共享目录

showmount -a 10.10.13.23
showmount -e 10.10.13.23

root@m1:~/katy/monitoring/vm# cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#  to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#

配置nfs共享目录

root@m1:~/katy/monitoring/vm# vim /etc/exports
/var/lib/xx/data/storage *(rw,sync,no_root_squash)

更新volume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: vmstorage
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    server: 10.10.13.23
    path: /var/lib/xx/data/storage  // 这里是nfs共享目录的地址
--- 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: vmstorage
  namespace: monitoring
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

重新apply pod.yaml,还是处于ContainerCreating状态,describe报错跟之前是一样的。

节点安装apt-get install nfs-common

重新apply pod.yaml, pod正常启动。

猜你喜欢

转载自blog.csdn.net/u010918487/article/details/105562341