Get the App
SLTechnology News&Howtos  ›  Servers  › 

Pv and PVC storage of K8s notes

Shulou Source: shulou.com Published: 2022-06-02 09:23:16 09月12日 Update

What are pv and pvc

1. PersistentVolume (PV) is a piece of network storage in the cluster that has been configured by the administrator. A resource in a cluster is like a node is a cluster resource. PV is a volume plug-in such as a volume, but has a life cycle independent of any single pod that uses PV. This API object captures the implementation details of the storage, that is, the NFS,iSCSI or cloud provider-specific storage system.

Types supported by PV

The commonly used types are

GCEPersistentDisk

AWSElasticBlockStore

AzureFile

AzureDisk

FC (Fibre Channel)

FlexVolume

Flocker

NFS

ISCSI

RBD (Ceph Block Device)

CephFS

Cinder (OpenStack block storage)

Glusterfs

VsphereVolume

Quobyte Volumes

HostPath

VMware Photon

Portworx Volumes

ScaleIO Volumes

2. Access mode of pv

ReadWriteOnce: read and write to a single node

ReadOnlyMany: multi-node read-only

ReadWriteMany: multi-node read and write. Only one mode can be used when mounting.

3. The recycling mode of pv

Retain-requires manual recycling by the administrator.

Recycle-clears the data in PV, which is equivalent to performing rm-rf / thevolume/*.

Delete-Delet

Create pv, which has been stored in nfs as an example

1. Install the nfs server

2. Create a storage path

3. Access directory authorization

Mkdir-p / data/test/v1

Echo "/ data/test/v1 * (rw,sync,no_root_squash)" > > / etc/exports

Exportfs-avr

Write yaml files

ApiVersion: v1kind: PersistentVolumemetadata: name: test01-pvspec: capacity: storage: 1Gi accessModes:-ReadWriteMany storageClassName: test01-pv persistentVolumeReclaimPolicy: Recycle nfs: path: / data/test/v1 server: 192.168.222.247

Kubectl create-f test01_pv.yaml

Binding of pvc

ApiVersion: v1kind: PersistentVolumeClaimmetadata: name: test01-pvc namespace: test01spec: storageClassName:-ReadWriteMany resources: requests: storage: 1Gi---apiVersion: v1kind: Podmetadata: name: myapp namespace: test01spec: containers:-name: myapp image: ikubernetes/myapp:v1 volumeMounts:-name: html mountPath: / usr/share/nginx/html volumes:-name: html persistentVolumeClaim: claimName: test01-pvc

Kubectl create-f test01_pod_pvc.yaml

View pvc and pod

Pv in bound state cannot be deleted directly

Tags: Storage nodes patterns clusters single administrators types resources management cycles objects commonly used manual providers plug-ins effects data files servers status Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft Huawei Shulou Information NVidia