Creating a storage class for GlusterFS
Create a storage class to provision GlusterFS storage.
Required user type or access level: Cluster administrator
To create a storage class for GlusterFS, specify the following field values in the storage class definition:
- metadata:
name
is the name of the storage class.
Note: Name must consist of lowercase alphanumeric characters, and must start and end with an alphanumeric character. You can use only these special characters in the name:-
and.
.
-
parameters:
-
resturl
is the Heketi REST URL that provisions volumes.-
Syntax for a GlusterFS server that is outside the IBM® Cloud Private cluster:
http://<Heketi_server_IP>:<Heketi_server_port>
-
Syntax for a GlusterFS cluster in the IBM® Cloud Private cluster:
http://<Heketi_service_cluster_IP>:<Heketi_service_port>
- To get the Heketi service, run the following command:
kubectl -n kube-system get service -l glusterfs=heketi-service
- To get the Heketi service cluster IP, run the following command:
kubectl -n kube-system get service <heketi-service-name> -o=jsonpath='{.spec.clusterIP}'
- To get the Heketi service port number, run the following command:
kubectl -n kube-system get service <heketi-service-name> -o=jsonpath='{.spec.ports[0].port}'
- To get the Heketi service, run the following command:
-
-
volumetype
is the optional parameter for the type of volume. The valid parameter values arenone
,replicate:<replicate_count>
, anddisperse:<data>:<redundancy_count>
. If you do not specify a volume type, the provisioner sets the volume type toreplicate:3
. -
volumenameprefix
is a prefix for the name of the volume. By default, dynamically provisioned volumes have the naming schema of vol_format. With the volumenameprefix
parameter in the storage class, you can prefix the volume name that you want.
-
To create a storage class for GlusterFS, you must complete the steps that are shown in the following example:
-
Create a YAML file that is named
glusterfs.yaml
and contains the following storage class definitions:apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: glusterfs provisioner: kubernetes.io/glusterfs parameters: resturl: "http://10.0.0.185:8080" restuser: "admin" secretName: "heketi-secret" secretNamespace: "kube-system" volumetype: replicate:3 volumenameprefix: "icp"
Note: If your GlusterFS cluster is in an IBM® Cloud Private environment, you must use the following parameter values:
- restuser must be "admin"
- secretName is the same secret that you used for Heketi authentication during GlusterFS installation
- secretNamespace must be "kube-system"
To make this your default storage class, add the annotation
storageclass.kubernetes.io/is-default-class
and set it totrue
. -
Create the storage class:
kubectl create -f glusterfs.yaml
The output resembles the following code:
storageclass "glusterfs" created
-
Verify that the storage class is created:
kubectl describe sc glusterfs