k8s笔记Pv、PVC存储-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

k8s笔记Pv、PVC存储

一、什么是 pv 和pvc 

创新互联是专业的西乌珠穆沁网站建设公司,西乌珠穆沁接单;提供成都网站建设、网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行西乌珠穆沁网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

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.247

kubectl create -f test01_pv.yaml

k8s 笔记 Pv、PVC 存储

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-pvc

kubectl create -f test01_pod_pvc.yaml

查看 pvc 和pod 

k8s 笔记 Pv、PVC 存储

绑定状态的pv 无法直接删除

 


本文名称:k8s笔记Pv、PVC存储
分享URL:http://kswsj.cn/article/jppihc.html

其他资讯