github.com/qsunny/k8s@v0.0.0-20220101153623-e6dca256d5bf/examples-master/volumes/glusterfs/README.md (about) 1 ## GlusterFS 2 3 [GlusterFS](http://www.gluster.org) is an open source scale-out filesystem. 4 These examples provide information about how to allow containers use GlusterFS 5 volumes. 6 7 The example assumes that you have already set up a GlusterFS server cluster and 8 have a working GlusterFS volume ready to use in the containers. 9 10 #### Prerequisites 11 12 * Set up a GlusterFS server cluster 13 * Create a GlusterFS volume 14 * If you are not using hyperkube, you may need to install the GlusterFS client 15 package on the Kubernetes nodes 16 ([Guide](http://gluster.readthedocs.io/en/latest/Administrator%20Guide/)) 17 18 #### Create endpoints 19 20 The first step is to create the GlusterFS endpoints definition in Kubernetes. 21 Here is a snippet of [glusterfs-endpoints.yaml](glusterfs-endpoints.yaml): 22 23 ```yaml 24 subsets: 25 - addresses: 26 - ip: 10.240.106.152 27 ports: 28 - port: 1 29 - addresses: 30 - ip: 10.240.79.157 31 ports: 32 - port: 1 33 ``` 34 35 The `subsets` field should be populated with the addresses of the nodes in the 36 GlusterFS cluster. It is fine to provide any valid value (from 1 to 65535) in 37 the `port` field. 38 39 Create the endpoints: 40 41 ```sh 42 $ kubectl create -f examples/volumes/glusterfs/glusterfs-endpoints.yaml 43 ``` 44 45 You can verify that the endpoints are successfully created by running 46 47 ```sh 48 $ kubectl get endpoints 49 NAME ENDPOINTS 50 glusterfs-cluster 10.240.106.152:1,10.240.79.157:1 51 ``` 52 53 We also need to create a service for these endpoints, so that they will 54 persist. We will add this service without a selector to tell Kubernetes we want 55 to add its endpoints manually. You can see 56 [glusterfs-service.yaml](glusterfs-service.yaml) for details. 57 58 Use this command to create the service: 59 60 ```sh 61 $ kubectl create -f examples/volumes/glusterfs/glusterfs-service.yaml 62 ``` 63 64 65 #### Create a Pod 66 67 The following *volume* spec in [glusterfs-pod.yaml](glusterfs-pod.yaml) 68 illustrates a sample configuration: 69 70 ```yaml 71 volumes: 72 - name: glusterfsvol 73 glusterfs: 74 endpoints: glusterfs-cluster 75 path: kube_vol 76 readOnly: true 77 ``` 78 79 The parameters are explained as the followings. 80 81 - **endpoints** is the name of the Endpoints object that represents a Gluster 82 cluster configuration. *kubelet* is optimized to avoid mount storm, it will 83 randomly pick one from the endpoints to mount. If this host is unresponsive, 84 the next Gluster host in the endpoints is automatically selected. 85 - **path** is the Glusterfs volume name. 86 - **readOnly** is the boolean that sets the mountpoint readOnly or readWrite. 87 88 Create a pod that has a container using Glusterfs volume, 89 90 ```sh 91 $ kubectl create -f examples/volumes/glusterfs/glusterfs-pod.yaml 92 ``` 93 94 You can verify that the pod is running: 95 96 ```sh 97 $ kubectl get pods 98 NAME READY STATUS RESTARTS AGE 99 glusterfs 1/1 Running 0 3m 100 ``` 101 102 You may execute the command `mount` inside the container to see if the 103 GlusterFS volume is mounted correctly: 104 105 ```sh 106 $ kubectl exec glusterfs -- mount | grep gluster 107 10.240.106.152:kube_vol on /mnt/glusterfs type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072) 108 ``` 109 110 You may also run `docker ps` on the host to see the actual container. 111 112 <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> 113 []() 114 <!-- END MUNGE: GENERATED_ANALYTICS -->