kubenetes入门学习-十三-存储卷2-动态存储卷供应StorageClass
最近学习k8s遇到很多问题,建了一个qq群:153144292,交流devops、k8s、docker等 存储卷存储类StorageClass的动态存储供应在这个nfs pv和pvc 实验中https://blog.csdn.net/yujin2010good/article/details/88564677我们是人为指定了大小那么当PVC申请的存储空间不一定有满足PVC要求的P...
最近学习k8s遇到很多问题,建了一个qq群:153144292,交流devops、k8s、docker等 存储卷
存储类StorageClass的动态存储供应
在这个nfs pv和pvc 实验中https://blog.csdn.net/yujin2010good/article/details/88564677我们是人为指定了大小
那么当PVC申请的存储空间不一定有满足PVC要求的PV事,这里肿么处理呢?这里就出现了StorageClass。
StorageClass为管理员提供了一种描述他们提供的存储的“类型”的方法。 不同的类型可能映射到服务质量级别,或备
份策略,或者由群集管理员确定的任意策略的PV上。 Kubernetes本身对于什么类别代表类型的存储没有明确的规定, 这个
概念在其他存储系统中可能会被称为“profiles”.
1)集群管理员预先创建存储类(StorageClass);
2)用户创建使用存储类的持久化存储声明(PVC:PersistentVolumeClaim);
3)存储持久化声明通知系统,它需要一个持久化存储(PV: PersistentVolume);
4)系统读取存储类的信息;
5)系统基于存储类的信息,在后台自动创建PVC需要的PV;
6)用户创建一个使用PVC的Pod;
7)Pod中的应用通过PVC进行数据的持久化;
8)而PVC使用PV进行数据的最终持久化处理。
这个过程如图:
KIND: StorageClass
VERSION: storage.k8s.io/v1
FIELDS:
allowVolumeExpansion <boolean>
allowedTopologies <[]Object>
apiVersion <string>
kind <string>
metadata <Object>
mountOptions <[]string> #挂载选项
parameters <map[string]string> #参数,取决于分配器,可以接受不同的参数。 例如,参数 type 的值 io1 和参数 iopsPerGB 特定于 EBS PV。当参数被省略时,会使用默认值。
provisioner <string> -required- #存储分配器,用来决定使用哪个卷插件分配 PV。该字段必须指定。
reclaimPolicy <string> #回收策略,可以是 Delete 或者 Retain。如果 StorageClass 对象被创建时没有指定 reclaimPolicy ,它将默认为 Delete。
volumeBindingMode <string> #卷的绑定模式
StorageClass 中包含 provisioner、parameters 和 reclaimPolicy 字段,当 class 需要动态分配
PersistentVolume 时会使用到。由于StorageClass需要一个独立的存储系统,此处就不再演示。从其他资
料查看定义StorageClass的方式如下:
ebs存储类定义
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: standard
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
mountOptions:
- debug
glusterfs存储类定义
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: glusterfs
provisioner: kubernetes.io/glusterfs
parameters:
type: "http://heketi.ilinux.io:8080"
restauthenabled: "false"
restuser: "ik8s"
restuserkey: "ik8s.io"
存储类有一个供应者的参数域,此参数域决定PV使用什么存储卷插件。参数必需进行设置:
这里没有对应环境,重点也不在存储之上,等学完k8s在研究学习
k8s中文社区文章可以参考
https://www.kubernetes.org.cn/4078.html
[root@master wolf3]# kubectl explain storageclass #storageclass也是k8s上的资源
KIND: StorageClass
VERSION: storage.k8s.io/v1
DESCRIPTION:
StorageClass describes the parameters for a class of storage for which
PersistentVolumes can be dynamically provisioned. StorageClasses are
non-namespaced; the name of the storage class according to etcd is in
ObjectMeta.Name.
FIELDS:
allowVolumeExpansion <boolean>
AllowVolumeExpansion shows whether the storage class allow volume expand
allowedTopologies <[]Object>
Restrict the node topologies where volumes can be dynamically provisioned.
Each volume plugin defines its own supported topology specifications. An
empty TopologySelectorTerm list means there is no topology restriction.
This field is only honored by servers that enable the VolumeScheduling
feature.
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
metadata <Object>
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
mountOptions <[]string>
Dynamically provisioned PersistentVolumes of this storage class are created
with these mountOptions, e.g. ["ro", "soft"]. Not validated - mount of the
PVs will simply fail if one is invalid.
parameters <map[string]string>
Parameters holds the parameters for the provisioner that should create
volumes of this storage class.
provisioner <string> -required-
Provisioner indicates the type of the provisioner.
reclaimPolicy <string>
Dynamically provisioned PersistentVolumes of this storage class are created
with this reclaimPolicy. Defaults to Delete.
volumeBindingMode <string>
VolumeBindingMode indicates how PersistentVolumeClaims should be
provisioned and bound. When unset, VolumeBindingImmediate is used. This
field is only honored by servers that enable the VolumeScheduling feature.
更多推荐
所有评论(0)