一、什么是 pv 和pvc
1、 PersistentVolume(PV)是集群中已由管理员配置的一段网络存储。 集群中的资源就像一个节点是一个集群资源。 PV是诸如卷之类的卷插件,但是具有独立于使用PV的任何单个pod的生命周期。 该API对象捕获存储的实现细节,即NFS,iSCSI或云提供商特定的存储系统。
PV 支持的类型
常用的 类型有
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、pv
的访问模式
ReadWriteOnce:单个节点读写
ReadOnlyMany:多节点只读
ReadWriteMany:多节点读写。挂载时只能使用一种模式。
3、pv
的回收模式
Retain – 需要管理员手工回收。
Recycle – 清除 PV 中的数据,效果相当于执行 rm -rf /thevolume/*。
Delete – 删除
创建 pv , 已nfs 存储为例
1、安装 nfs 服务器
2、创建存储路径
3、访问目录授权
mkdir -p /data/test/v1
echo "/data/test/v1 *(rw,sync,no_root_squash)" >> /etc/exports
exportfs -avr
编写yaml 文件
apiVersion: v1 kind: PersistentVolume metadata: name: test01-pv spec: capacity: storage: 1Gi accessModes: - ReadWriteMany storageClassName: test01-pv persistentVolumeReclaimPolicy: Recycle nfs: path: /data/test/v1 server: 192.168.222.247kubectl create -f test01_pv.yaml
pvc 的绑定
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: test01-pvc namespace: test01 spec: storageClassName: test01-pv accessModes: - ReadWriteMany resources: requests: storage: 1Gi --- apiVersion: v1 kind: Pod metadata: name: myapp namespace: test01 spec: containers: - name: myapp image: ikubernetes/myapp:v1 volumeMounts: - name: html mountPath: /usr/share/nginx/html volumes: - name: html persistentVolumeClaim: claimName: test01-pvckubectl create -f test01_pod_pvc.yaml
查看 pvc 和pod
绑定状态的pv 无法直接删除
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:k8s笔记Pv、PVC存储-创新互联
文章链接:https://www.cdcxhl.com/article48/dhdshp.html
成都网站建设公司_创新互联,为您提供网站内链、云服务器、网站营销、软件开发、Google、品牌网站制作
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联