2017-03-27 12:41:10 +00:00
## GlusterFS
2015-03-26 18:53:21 +00:00
2017-03-27 12:41:10 +00:00
[GlusterFS ](http://www.gluster.org ) is an open source scale-out filesystem. These examples provide information about how to allow containers use GlusterFS volumes.
2015-03-26 18:53:21 +00:00
2017-05-25 05:13:24 +00:00
There are couple of ways to use GlusterFS as a persistent data store in application pods.
*) Static Provisioning of GlusterFS Volumes.
*) Dynamic Provisioning of GlusterFS Volumes.
### Static Provisioning
Static Provisioning of GlusterFS Volumes is analogues to creation of a PV ( Persistent Volume) resource by specifying the parameters in it. This
also need a working GlusterFS cluster/trusted pool available to carve out GlusterFS volumes.
2017-03-27 12:41:10 +00:00
The example assumes that you have already set up a GlusterFS server cluster and have a working GlusterFS volume ready to use in the containers.
2015-03-26 18:53:21 +00:00
2017-05-25 05:13:24 +00:00
#### Prerequisites
2015-03-26 18:53:21 +00:00
2017-03-27 12:41:10 +00:00
* Set up a GlusterFS server cluster
* Create a GlusterFS volume
* If you are not using hyperkube, you may need to install the GlusterFS client package on the Kubernetes nodes ([Guide](http://gluster.readthedocs.io/en/latest/Administrator%20Guide/))
2015-05-14 18:59:34 +00:00
2017-05-25 05:13:24 +00:00
#### Create endpoints
2015-07-17 22:35:41 +00:00
2017-03-27 12:41:10 +00:00
The first step is to create the GlusterFS endpoints definition in Kubernetes. Here is a snippet of [glusterfs-endpoints.json ](glusterfs-endpoints.json ):
2015-05-24 07:15:58 +00:00
2015-05-14 18:59:34 +00:00
```
2017-03-27 12:41:10 +00:00
"subsets": [
{
"addresses": [{ "ip": "10.240.106.152" }],
"ports": [{ "port": 1 }]
},
{
"addresses": [{ "ip": "10.240.79.157" }],
"ports": [{ "port": 1 }]
}
]
2015-05-14 18:59:34 +00:00
```
2015-07-17 02:01:02 +00:00
2017-03-27 12:41:10 +00:00
The `subsets` field should be populated with the addresses of the nodes in the GlusterFS cluster. It is fine to provide any valid value (from 1 to 65535) in the `port` field.
2015-05-14 18:59:34 +00:00
2017-03-27 12:41:10 +00:00
Create the endpoints:
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```sh
2016-06-21 22:43:29 +00:00
$ kubectl create -f examples/volumes/glusterfs/glusterfs-endpoints.json
2015-05-14 18:59:34 +00:00
```
You can verify that the endpoints are successfully created by running
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```sh
2015-07-07 18:20:33 +00:00
$ kubectl get endpoints
2015-05-14 18:59:34 +00:00
NAME ENDPOINTS
glusterfs-cluster 10.240.106.152:1,10.240.79.157:1
```
2015-03-26 18:53:21 +00:00
2017-03-27 12:41:10 +00:00
We also need to create a service for these endpoints, so that they will persist. We will add this service without a selector to tell Kubernetes we want to add its endpoints manually. You can see [glusterfs-service.json ](glusterfs-service.json ) for details.
2015-08-31 05:52:51 +00:00
Use this command to create the service:
```sh
2016-06-21 22:43:29 +00:00
$ kubectl create -f examples/volumes/glusterfs/glusterfs-service.json
2015-08-31 05:52:51 +00:00
```
2017-05-25 05:13:24 +00:00
#### Create a Pod
2015-03-26 18:53:21 +00:00
2017-03-27 12:41:10 +00:00
The following *volume* spec in [glusterfs-pod.json ](glusterfs-pod.json ) illustrates a sample configuration:
2015-03-26 18:53:21 +00:00
2015-07-20 16:40:32 +00:00
```json
2017-03-27 12:41:10 +00:00
"volumes": [
{
"name": "glusterfsvol",
"glusterfs": {
"endpoints": "glusterfs-cluster",
"path": "kube_vol",
"readOnly": true
2015-03-26 18:53:21 +00:00
}
2017-03-27 12:41:10 +00:00
}
]
2015-03-26 18:53:21 +00:00
```
2015-07-24 21:52:18 +00:00
The parameters are explained as the followings.
2015-03-26 18:53:21 +00:00
2017-03-27 12:41:10 +00:00
- **endpoints** is the name of the Endpoints object that represents a Gluster cluster configuration. *kubelet* is optimized to avoid mount storm, it will randomly pick one from the endpoints to mount. If this host is unresponsive, the next Gluster host in the endpoints is automatically selected.
2015-07-24 21:52:18 +00:00
- **path** is the Glusterfs volume name.
- **readOnly** is the boolean that sets the mountpoint readOnly or readWrite.
2015-03-26 18:53:21 +00:00
2015-05-14 18:59:34 +00:00
Create a pod that has a container using Glusterfs volume,
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```sh
2016-06-21 22:43:29 +00:00
$ kubectl create -f examples/volumes/glusterfs/glusterfs-pod.json
2015-03-26 18:53:21 +00:00
```
2015-07-17 02:01:02 +00:00
2015-05-14 18:59:34 +00:00
You can verify that the pod is running:
2015-03-26 18:53:21 +00:00
2015-07-20 16:40:32 +00:00
```sh
2015-03-26 18:53:21 +00:00
$ kubectl get pods
2015-07-07 18:20:33 +00:00
NAME READY STATUS RESTARTS AGE
glusterfs 1/1 Running 0 3m
2015-05-14 18:59:34 +00:00
```
2017-03-27 12:41:10 +00:00
You may execute the command `mount` inside the container to see if the GlusterFS volume is mounted correctly:
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```sh
2017-03-27 12:41:10 +00:00
$ kubectl exec glusterfs -- mount | grep gluster
2017-05-25 05:13:24 +00:00
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)
```
2015-03-26 18:53:21 +00:00
2015-05-14 18:59:34 +00:00
You may also run `docker ps` on the host to see the actual container.
2015-05-14 22:12:45 +00:00
2017-05-25 05:13:24 +00:00
### Dynamic Provisioning of GlusterFS Volumes:
2015-05-14 22:12:45 +00:00
2017-05-25 05:13:24 +00:00
Dynamic Provisioning means provisioning of GlusterFS volumes based on a Storage class. Please refer [this guide ](./../../persistent-volume-provisioning/README.md )
.
2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
2016-06-21 22:43:29 +00:00
[![Analytics ](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/examples/volumes/glusterfs/README.md?pixel )]()
2015-07-14 00:13:09 +00:00
<!-- END MUNGE: GENERATED_ANALYTICS -->