Skip to content

Commit

Permalink
gluster doc review feedbacks; fix Endpoints indexing
Browse files Browse the repository at this point in the history
Signed-off-by: Huamin Chen <hchen@redhat.com>
  • Loading branch information
rootfs committed Apr 1, 2015
1 parent 63c7251 commit a27ddb6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/glusterfs/README.md
@@ -1,12 +1,12 @@
## Glusterfs

[Glusterfs](http://www.gluster.org) is an open source scale-out filesystem. These examples provide information about how to allow Docker containers use Glusterfs volumes.
[Glusterfs](http://www.gluster.org) is an open source scale-out filesystem. These examples provide information about how to allow containers use Glusterfs volumes.

The example consists of a pod that runs on hosts that install Glusterfs client package.
The example assumes that the Glusterfs client package is installed on all nodes.

### Prerequisites

Install Glusterfs client package on the hosts.
Install Glusterfs client package on the Kubernetes hosts.

### Create a POD

Expand All @@ -24,12 +24,14 @@ The following *volume* spec illustrates a sample configuration.
}
```

The parameters are explained as the followings. **endpoints** is endpoint name that defines Gluster service. **kubelet** is optimized to avoid mount storm, it will randomly pick one from the hosts to mount. If this host is unresponsive, the next host in the array is automatically selected. **path** is the Glusterfs volume name. **readOnly** is the boolean that sets the mountpoint readOnly or readWrite. **helper** can be a command that can be executed prior to mounting the filesystem.
The parameters are explained as the followings. **endpoints** is endpoints name that represents a Gluster cluster configuration. **kubelet** is optimized to avoid mount storm, it will randomly pick one from the hosts 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. **helper** can be a command that can be executed prior to mounting the filesystem.

Detailed POD and Gluster cluster endpoints examples can be found at [v1beta3/](v1beta3/) and [endpoints/](endpoints/)

```shell
# create gluster cluster endpoints
$ kubectl create -f examples/glusterfs/endpoints/glusterfs-endpoints.json
# create a container using gluster volume
$ kubectl create -f examples/glusterfs/v1beta3/glusterfs.json
```
Once that's up you can list the pods and endpoint in the cluster, to verify that the master is running:
Expand Down
6 changes: 3 additions & 3 deletions pkg/volume/glusterfs/glusterfs.go
Expand Up @@ -201,20 +201,20 @@ func (glusterfsVolume *glusterfs) execMount(hosts *api.Endpoints, path string, m
opt = []string{"-o", "rw"}
}

l := len(hosts.Subsets[0].Addresses)
l := len(hosts.Subsets)
// avoid mount storm, pick a host randomly
start := rand.Int() % l
// iterate all hosts until mount succeeds.
for i := start; i < start+l; i++ {
if helper == "" {
arg := []string{"-t", "glusterfs", hosts.Subsets[0].Addresses[i%l].IP + ":" + path, mountpoint}
arg := []string{"-t", "glusterfs", hosts.Subsets[i%l].Addresses[0].IP + ":" + path, mountpoint}
mountArgs = append(arg, opt...)
glog.Infof("Glusterfs: mount cmd: mount %v", strings.Join(mountArgs, " "))
command = glusterfsVolume.exe.Command("mount", mountArgs...)
} else {
// if helper is provided, make a cmd like "helper_cmd helper_arg mount -t glusterfs mnt -o option"
helper_array := strings.Split(helper, " ")
arg := []string{"mount", "-t", "glusterfs", hosts.Subsets[0].Addresses[i%l].IP + ":" + path, mountpoint}
arg := []string{"mount", "-t", "glusterfs", hosts.Subsets[i%l].Addresses[0].IP + ":" + path, mountpoint}
mountArgs = append(arg, opt...)
args := append(helper_array[1:], mountArgs...)
glog.Infof("Glusterfs: mount cmd: %s %v", helper_array[0], strings.Join(args, " "))
Expand Down

0 comments on commit a27ddb6

Please sign in to comment.