diff --git a/examples/glusterfs/README.md b/examples/glusterfs/README.md index 39ba2bfdccfc..93d799485709 100644 --- a/examples/glusterfs/README.md +++ b/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 @@ -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: diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 3db42e36be97..8fa90c75bc43 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -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, " "))