Volume

作者: cdz620 | 来源:发表于2020-03-04 09:39 被阅读0次

官网url

Volume

  • 由pod管理生存周期
  • 支持多种类型的volume
  • 可以同时使用不同的volume

Volume 类型

emptyDir

  • pod 分配到node时创建
  • 存储基于环境主机的介质
  • 可以设置成 “Memory”,使用tmpfs,提高存取效率
  • demo
apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: gcr.io/google_containers/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}

hostPath

本地主机路径

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: gcr.io/google_containers/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      # directory location on host
      path: /data

PersistentVolume & PersistentVolumeClaims

PersistentVolume(PV)

网络存储,kubernetes推荐的解决方案,更多 http://kubernetes.io/docs/user-guide/persistent-volumes/#introduction

PersistentVolumeClaims(PVC)

用户向 PersistenVolume 请求存储空间

StorageClass

  • 存储提供商的配置说明,
  • annotation:volume.beta.kubernetes.io/storage-class,对应的value用来匹配动态pv
  • 有设置该值的,和pvc请求中有相同值的匹配,没有设置的pv和没有设置的pvc匹配
  • 如果selector非空,不能使用动态的pv
  • 更多详细匹配规则: http://kubernetes.io/docs/user-guide/persistent-volumes/#Class

供给方式

  • static: 先创建好一定规格的pv
  • dynamically: pvc请求时,动态创建

Binding 存储交互匹配

  • control loop 监听新的pvc请求,接收到pvc请求后,匹配pvc的存储要求,试图将pv和pvc绑定在一起
  • 如果是动态的pv,始终都能匹配
  • 匹配规则,pvc的要求必须是pv的子集,待匹配的pv的容量必须必pvc大。eg:50G pvc 可以和100G 静态pv 匹配

using 使用

权限,根据用户指定的访问权限访问;pod在使用时,通过pvc存储。

releasing 释放

pod删除时,并不一定会释放数据,需要根据策略来决定是否回收空间。

Reclaiming 回收

回收策略告诉集群当volume释放时,如何处理

  • Retained 保留,允许手动回收资源
  • Recycled(rm -fr /thevolume/*) 回收
  • Deleted 删除,动态供给方式都是删除volume
  • Currently, only NFS and HostPath support recycling. AWS EBS, GCE PD and Cinder volumes support deletion.

Recycling

可以自定义回收回收器,通过kube-controller-manager 参数控制

volume 阶段

  • Available – 可用
  • Bound – 绑定状态
  • Released – pvc已经删除,资源还没回收
  • Failed – 自动回收失败

相关文章

网友评论

      本文标题:Volume

      本文链接:https://www.haomeiwen.com/subject/fyfdchtx.html