2015-07-14 00:13:09 +00:00
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
2016-06-10 23:46:46 +00:00
<!-- BEGIN STRIP_FOR_RELEASE -->
2016-07-15 09:44:58 +00:00
< img src = "http://kubernetes.io/kubernetes/img/warning.png" alt = "WARNING"
2016-06-10 23:46:46 +00:00
width="25" height="25">
2016-07-15 09:44:58 +00:00
< img src = "http://kubernetes.io/kubernetes/img/warning.png" alt = "WARNING"
2016-06-10 23:46:46 +00:00
width="25" height="25">
2016-07-15 09:44:58 +00:00
< img src = "http://kubernetes.io/kubernetes/img/warning.png" alt = "WARNING"
2016-06-10 23:46:46 +00:00
width="25" height="25">
2016-07-15 09:44:58 +00:00
< img src = "http://kubernetes.io/kubernetes/img/warning.png" alt = "WARNING"
2016-06-10 23:46:46 +00:00
width="25" height="25">
2016-07-15 09:44:58 +00:00
< img src = "http://kubernetes.io/kubernetes/img/warning.png" alt = "WARNING"
2016-06-10 23:46:46 +00:00
width="25" height="25">
< h2 > PLEASE NOTE: This document applies to the HEAD of the source tree< / h2 >
If you are using a released version of Kubernetes, you should
refer to the docs that go with that version.
2016-09-01 21:40:55 +00:00
<!-- TAG RELEASE_LINK, added by the munger automatically -->
< strong >
The latest release of this document can be found
[here ](http://releases.k8s.io/release-1.4/examples/volumes/glusterfs/README.md ).
2016-06-10 23:46:46 +00:00
Documentation for other releases can be found at
[releases.k8s.io ](http://releases.k8s.io ).
< / strong >
--
<!-- END STRIP_FOR_RELEASE -->
2015-07-14 00:13:09 +00:00
<!-- END MUNGE: UNVERSIONED_WARNING -->
2015-07-17 22:35:41 +00:00
2015-03-26 18:53:21 +00:00
## Glusterfs
[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-05-14 18:59:34 +00:00
The example assumes that you have already set up a Glusterfs server cluster and the Glusterfs client package is installed on all Kubernetes nodes.
2015-03-26 18:53:21 +00:00
### Prerequisites
2015-05-14 18:59:34 +00:00
Set up Glusterfs server cluster; install Glusterfs client package on the Kubernetes nodes. ([Guide](https://www.howtoforge.com/high-availability-storage-with-glusterfs-3.2.x-on-debian-wheezy-automatic-file-replication-mirror-across-two-storage-servers))
### Create endpoints
2015-07-17 22:35:41 +00:00
2015-05-24 07:15:58 +00:00
Here is a snippet of [glusterfs-endpoints.json ](glusterfs-endpoints.json ),
2015-05-14 18:59:34 +00:00
```
"addresses": [
{
"IP": "10.240.106.152"
}
],
"ports": [
{
2015-06-09 23:06:14 +00:00
"port": 1
2015-05-14 18:59:34 +00:00
}
]
```
2015-07-17 02:01:02 +00:00
2015-07-24 21:52:18 +00:00
The "IP" field should be filled with the address of a node in the Glusterfs server cluster. In this example, it is fine to give any valid value (from 1 to 65535) to the "port" field.
2015-05-14 18:59:34 +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
2015-08-31 05:52:51 +00:00
We need also create a service for this endpoints, so that the endpoints will be persistented. 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.
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
```
2015-03-26 18:53:21 +00:00
### Create a POD
2015-05-24 07:15:58 +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
2015-03-26 18:53:21 +00:00
{
"name": "glusterfsvol",
"glusterfs": {
"endpoints": "glusterfs-cluster",
"path": "kube_vol",
"readOnly": true
}
}
```
2015-07-24 21:52:18 +00:00
The parameters are explained as the followings.
2015-03-26 18:53:21 +00:00
2015-07-24 21:52:18 +00:00
- **endpoints** is endpoints name 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.
- **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
2015-07-07 18:20:33 +00:00
$ kubectl get pods glusterfs -t '{{.status.hostIP}}{{"\n"}}'
10.240.169.172
2015-05-14 18:59:34 +00:00
```
2015-07-07 18:20:33 +00:00
You may ssh to the host (the hostIP) and run 'mount' to see if the Glusterfs volume is mounted,
2015-07-17 02:01:02 +00:00
2015-07-20 16:40:32 +00:00
```sh
2015-05-14 18:59:34 +00:00
$ mount | grep kube_vol
10.240.106.152:kube_vol on /var/lib/kubelet/pods/f164a571-fa68-11e4-ad5c-42010af019b7/volumes/kubernetes.io~glusterfs/glusterfsvol 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
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 -->