Get the App
SLTechnology News&Howtos  ›  Servers  › 

NFS service creates PV resources

Shulou Source: shulou.com Published: 2022-06-03 05:19:21 09月22日 Update

To do PV based on NFS service:

Install NFS service and rpcbind service: 1. [root@master yaml] # yum install-y nfs-utils rpcbind # note that NFS service should be installed in all three. 2. [root@master yaml] # vim / etc/exports file add / nfsdata * (rw,sync,no_root_squash) 4. [root@master yaml] # mkdir / nfsdata 5. [root@master yaml] # systemctl start rpcbind 6. [root@master yaml] # systemctl start nfs-server.service 7. [root@master yaml] # showmount-e Export list for master: / nfsdata *

Create a PV resource object:

Vim nfs-pv.yamlapiVersion: v1kind: PersistentVolumemetadata: name: testspec: capacity given by capacity:# storage: access mode supported by 1Gi accessModes:#PV-ReadWriteOnce# here means that persistentVolumeReclaimPolicy: Recycle#pv can only be mounted to a single node in a read-write manner: the recycling policy of storageClassName: nfs# indicates that the name of the storage class defined by storageClassName: nfs# should be the same as the storage class name defined above Path: / nfsdata/pv1# specify the directory of NFS server: 192.168.1." specify the IP execution nfs-pv.yaml file of the NFS server: * * `kubectl apply-f nfs-pv.yaml `* * persistentvolume/test created * * `kubectl get pv` * * NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE test 1Gi RWO Recycle * * Available * * Nfs 7s * * Note here that the STATUS status is Available before it can be used. **

Access modes supported by pv:

ReadWriteOnce: the access mode is that you can only mount to a single node in read-write mode.

ReadWriteMany: the access mode is that you can only mount to multiple nodes in a read-write manner.

ReadOnlyMany: the access mode is that you can only mount to multiple nodes as read-only.

Recycling strategy for PV storage space:

Recycle: automatically clears data.

Retain: requires manual recycling by the administrator.

Delete: dedicated to cloud storage.

The correlation between PV and PVC: through storageClassName and accessModes

Create PVC: vim nfs-pvc.yamlapiVersion: v1kind: PersistentVolumeClaimmetadata: name: testspec: accessModes:-ReadWriteOnce# to define the access mode, which must be consistent with the Pv definition. Resources: requests: storage: 1Gi# request capacity size storageClassName: nfs# storage class name must be consistent with the pv definition.

Tags: Mode service storage mode node consistent name single multiple size capacity data file policy support resource clear object manual server Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS NVidia OPPO Reno Docker Shulou Information