glusterfs

GlusterFS (https://www.gluster.org) is a scalable, network-attached storage filesystem. The glusterfs volume type allows you to mount GlusterFS volume into your Pod. Just like NFS volume, the data in glusterfs volume is persistent across the Pod lifetime. If the Pod is terminated, the data is still accessible in glusterfs volume. You should build the GlusterFS system before using glusterfs volume.

Check whether glusterfs works before you go. By using glusterfs volume information on GlusterFS servers, you can see currently available volumes. By using mount -t glusterfs <glusterfs server>:/<volume name> <local mounted point> on local, you can check whether the GlusterFS system can be successfully mounted.

Since the volume replica in GlusterFS must be greater than 1, let's assume we have two replicas in the servers gfs1 and gfs2, and the volume name is gvol.

First, we need to create an endpoint acting as a bridge for gfs1 and gfs2:

$ cat 2-6-4_gfs-endpoint.yaml
kind: Endpoints
apiVersion: v1
metadata:
name: glusterfs-cluster
subsets:
-
addresses:
-
ip: <gfs1 server ip>
ports:
-
port: 1
-
addresses:
-
ip: <gfs2 server ip>
ports:
-
port: 1

# create endpoints
$ kubectl create –f 2-6-4_gfs-endpoint.yaml

Then, we can use kubectl get endpoints to check the endpoint was created properly:

$kubectl get endpoints
NAME ENDPOINTS AGE
glusterfs-cluster <gfs1>:1,<gfs2>:1 12m

After that, we should be able to create the Pod with glusterfs volume by glusterfs.yaml. The parameters of the glusterfs volume definition are glusterfs.endpoints, which specify the endpoint name we just created, and glusterfs.path, which is the volume name gvol. glusterfs.readOnly is used to set whether the volume is mounted in read-only mode:

$ cat 2-6-4_glusterfs.yaml
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
spec:
containers:
-
image: ubuntu
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: ubuntu
volumeMounts:
-
mountPath: /data-mount
name: data
volumes:
-
name: data
glusterfs:
endpoints: glusterfs-cluster
path: gvol

Let's check the volume setting with kubectl describle:

Volumes:
data:
Type: Glusterfs (a Glusterfs mount on the host that shares a pod's lifetime)
EndpointsName: glusterfs-cluster
Path: gvol
ReadOnly: false

Using docker inspect, you should be able to see that the mounted source is /var/lib/kubelet/pods/<id>/volumes/kubernetes.io~glusterfs/data to the destination /data-mount.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.83.253