kubernetes in action - Volumes

Volume解决Kubernetes的存储的问题

对于Pod使用的存储,抽象为volume,volume伴随着Pod的创建而创建,消失而同时消失,不能单独的创建

这样的好处,是存储的塑胶不会因为某个container重启而丢失,因为volume是pod级别的

还有好处是,volume是pod资源,所以所有Pod中的container都可以共享访问这个volume,这样非常的方便

但是需要在contain中去mount这个volume,可以mount到任意目录,比如下面这个例子,

ContentAgent会产生内容html到/var/html,这个目录对应于Volume publicHtml,
WebServer会通过/var/htdocs读取Volume publicHtml中的数据,并把日志通过/var/logs/写到Volume logVol中
最后LogRotator会从Volume logVol消费logs

 

volume有很多种类型,

- emptyDir—A simple empty directory used for storing transient data.
- hostPath—Used for mounting directories from the worker node’s filesystem into the pod.
- gitRepo—A volume initialized by checking out the contents of a Git repository.
- nfs—An NFS share mounted into the pod.
- gcePersistentDisk (Google Compute Engine Persistent Disk), awsElastic-
- BlockStore (Amazon Web Services Elastic Block Store Volume), azureDisk (Microsoft Azure Disk Volume)—Used for mounting cloud provider-specific storage.
- cinder, cephfs, iscsi, flocker, glusterfs, quobyte, rbd, flexVolume, vsphere-Volume, photonPersistentDisk, scaleIO—Used for mounting other types of network storage.
- configMap, secret, downwardAPI—Special types of volumes used to expose certain Kubernetes resources and cluster information to the pod.
- persistentVolumeClaim—A way to use a pre- or dynamically provisioned persistent storage. (We’ll talk about them in the last section of this chapter.)

其中,

emptyDir最常用,特点是pod删除后数据会丢失,用户container间交互数据或者纯计算的中间结果

 

hostPath,mount到node的目录,这样数据就不会因为pod删除而丢失

 

当然,如果要跨节点的恢复数据,就需要用到分布式的volume,比如,gcePersistentDisk

 

PersistentVolumeClaims,提供一种抽象来封装底层各种具体的存储 

 

 

这样的好处,user不需要了解和配置具体的存储,可以直接使用,那些事情交给Admin去做

 

Dynamic provisioning of PersistentVolumes

提前配置好,Persistent Volume Provisioner和Storage Class,仅仅在需要的时候才会自动产生Persistent Volume

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值