044. clustered storage -StorageClass

一 StoragClass

1.1 StorageClass Overview

StorageClass as an abstract definition of storage resources, set by the user application for PVC shield the details of the back-end storage, while reducing the user's attention to the details of storage resources, on the other hand reduces the administrator to manually manage PV work automatically by the system PV creation and completion of binding, to achieve dynamic resource supply.
Based on dynamic resource provisioning mode StorageClass will gradually become the standard platform for cloud storage configuration mode. StorageClass definition parameters include name, backend storage provider (Provisioner) and back-end storage configuration.
Once StorageClass is created, it will not be modified. For a change, you can only delete the definition of the reconstruction of the original StorageClass.
Example 1: standard named StorageClass defined, the provider of aws-ebs, which is a type parameter, the value gp2.
[root@k8smaster01 study]# vi awsclass01.yaml
  1 kind: StorageClass
  2 apiVersion: storage.k8s.io/v1
  3 metadata:
  4   name: standard
  5 provisioner: kubernetes.io/aws-bs
  6 parameters:
  7   type: gp2
  8 

1.2 StorageClass configuration parameters

  • Provider (Provisioner)
Contributors describe storage resources, it can be seen as back-end storage drive. Kubernetes are currently supported by Provisioner to "kubernetes.io/" for the beginning, users can also use the back-end storage provider to customize.
  • Parameters (Parameters)
Parameter provider backend storage resources provided, comprising different Provisioner different parameter settings. Some may not display the parameter settings, Provisioner uses its default value.

1.3 Common Provisioner

  • AWSEBS storage volumes
  1 kind: StorageClass
  2 apiVersion: storage.k8s.io/v1
  3 metadata:
  4   name: slow
  5 provisioner: kubernetes.io/aws-ebs
  6 parameters:
  7   type: io1
  8   zone: us-east-1d
  9   iopsPerGB: "10"
 10 
Parameters are as follows (For details, refer AWSEBS document):
    • type: The options are io1, gp2, sc1, st1, the default value gp2.
    • zone: the name AWSzone.
    • iopsPerGB: only io1 type Volume, meaning / O per second of the number of operations I per GiB.
    • encrypted: whether to encrypt.
    • kmsKeyId: Amazon Resource Name when encryption.
  • GCEPD storage volumes
  1 kind: StorageClass
  2 apiVersion: storage.k8s.io/v1
  3 metadata:
  4   name: slow
  5 provisioner: kubernetes.io/gce-pd
  6 parameters:
  7   type: pd-standard
  8   zone: us-centrall-a
  9 
Parameters are as follows (For details, refer GCE documentation):
    • type: The options are pd-standard, pd-ssd, the default value pd-standard.
    • zone: GCEzone name.
  • GlusterFS storage volumes
  1 apiVersion: storage.k8s.io/v1
  2 kind: StorageClass
  3 metadata:
  4   name: slow
  5 provisioner: kubernetes.io/glusterfes
  6 parameters:
  7   resturl: "http://127.0.0.1:8081"
  8   clusterid: "xxxxxxxxxxxx"
  9   restauthenabled: "true"
 10   restuser: "admin"
 11   secretNamespace: "default"
 12   secretName: "heketi-secret"
 13   gidMin: "40000"
 14   gidMax: "50000"
 15   volumetype: "replicate:3"
 16 
Parameters are as follows (For details, refer GlusterFS and Heketi documents):
    • resturl: GlusterREST Service (Heketi) URL address for auto-complete GlusterFSvolume settings.
    • restauthenabled: Whether to enable security for GlusterREST service.
    • restuser: Access GlusterREST service user name.
    • secretNamespace and secretName: save password access GlusterREST Secret Service resource object name.
    • clusterid:GlusterFS的ClusterID。
    • gidMin and gidMax: StorageClass the GID range, when the PV is set for dynamic resource provisioning GID.
    • volumetype: Volume type GlusterFS disposed inside of, for example, replicate: 3 (Replicate type, 3 copies); disperse: 4: 2 (Disperse type, the data parts 4, two redundancy; "none" (Distribute type).
  • OpenStackCinder storage volumes
  1 kind: StorageClass
  2 apiVersion: storage.k8s.io/v1
  3 metadata:
  4   name: gold
  5 provisioner: kubernetes.io/cinder
  6 parameters:
  7   type: fast
  8   availability: nova
  9 
Parameters described below.
    • type: Cinder's VolumeType, the default value is empty.
    • availability: AvailabilityZone, the default value is empty.

1.4 Set the default StorageClass

To set a default in the system StorageClass, you first need to enable admission controller called DefaultStorageClass, that increase in kube-apiserver command-line parameters --admission-control in:
--admission-control-...,DefaultStorageClass
[root@k8smaster01 study]# vi /etc/kubernetes/manifests/kube-apiserver.yaml
  1 ……
  2     - --enable-admission-plugins=NodeRestriction,DefaultStorageClass
  3 ……
  4 
[root@k8smaster01 study]# systemctl restart docker kubelet
然后,在StorageClass的定义中设置一个annotation:
[root@k8smaster01 study]# vi defaultclass01.yaml
  1 kind: StorageClass
  2 apiVersion: storage.k8s.io/v1
  3 metadata:
  4   name: gold
  5   annotations:
  6     storageclass.beta.kubernetes.io/is-default-class="true"
  7 provisioner: kubernetes.io/gce-pd
  8 parameters:
  9   type: pd-ssd
 10 
通过kubectl create命令创建成功后,查看StorageClass列表,可以看到名为gold的StorageClass被标记为default:

二 动态管理存储卷

2.1 glusterfs

见《附009.Kubernetes永久存储之GlusterFS独立部署》和《附010.Kubernetes永久存储之GlusterFS超融合部署》。

Guess you like

Origin www.cnblogs.com/itzgr/p/12625522.html