码迷,mamicode.com
首页 > Web开发 > 详细

Kubernetes-PV/PVC

时间:2020-01-15 10:02:47      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:meta   sed   work   允许   let   volumes   lock   用户   ast   

PV (Persistent Volume)

和Volume的区别

  • 只能是网络存储
  • 独立于Pod之外

PV支持的主流存储方案:

  • GCEPersistentDisk
  • AWSElasticBlockStore
  • AzureFile
  • AzureDisk
  • FC (Fibre Channel)
  • Flocker
  • NFS
  • iSCSI
  • RBD (Ceph Block Device)
  • CephFS
  • Cinder (OpenStack block storage)
  • Glusterfs
  • VsphereVolume
  • Quobyte Volumes
  • HostPath (single node testing only – local storage is not supported in any way and WILL NOT WORK in a multi-node cluster)
  • VMware Photon

创建PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv001
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle 
  nfs:
    path: /data/k8s/
    server: 172.16.1.131

accessModes

  • ReadWriteOnce – PV以 read-write 挂载到一个节点
  • ReadOnlyMany – PV以read-only方式挂载到多个节点
  • ReadWriteMany – PV以read-write方式挂载到多个节点

Reclaim

当前支持的回收策略:

  • Retain – 允许用户手动回收
  • Recycle – 删除PV上的数据 (“rm -rf /thevolume/*”)
  • Delete – 删除PV

Phase

  • Available – PV可以被使用
  • Bound – PV被绑定到PVC
  • Released – 被绑定的PVC被删除,可以被Reclaim
  • Failed – 自动回收失败

PVC (Persistent Volume Claim)

创建PVC

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 8Gi

Phase

Pending – 等待可用的PV
Bound – PV被绑定到PVC
Lost – 找不到绑定的PV

在Pod中使用

kind: Pod
apiVersion: v1
metadata:
name: mypod
spec:
containers:
- name: myfrontend
  image: dockerfile/nginx
  volumeMounts:
  - mountPath: "/var/www/html"
    name: mypd
volumes:
- name: mypd
  persistentVolumeClaim:
    claimName: myclaim

Kubernetes-PV/PVC

标签:meta   sed   work   允许   let   volumes   lock   用户   ast   

原文地址:https://www.cnblogs.com/wangyiyang/p/12194759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!