mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	Merge pull request #8266 from caesarxuchao/gluster-example
Update examples/glusterfs to v1beta3; add desciption of Glusterfs endpoints in README.md
This commit is contained in:
		@@ -74,6 +74,11 @@ func validateObject(obj runtime.Object) (errors []error) {
 | 
				
			|||||||
			t.Namespace = api.NamespaceDefault
 | 
								t.Namespace = api.NamespaceDefault
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		errors = validation.ValidatePodTemplate(t)
 | 
							errors = validation.ValidatePodTemplate(t)
 | 
				
			||||||
 | 
						case *api.Endpoints:
 | 
				
			||||||
 | 
							if t.Namespace == "" {
 | 
				
			||||||
 | 
								t.Namespace = api.NamespaceDefault
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							errors = validation.ValidateEndpoints(t)
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return []error{fmt.Errorf("no validation defined for %#v", obj)}
 | 
							return []error{fmt.Errorf("no validation defined for %#v", obj)}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -161,8 +166,9 @@ func TestExampleObjectSchemas(t *testing.T) {
 | 
				
			|||||||
		"../examples/iscsi": {
 | 
							"../examples/iscsi": {
 | 
				
			||||||
			"iscsi": &api.Pod{},
 | 
								"iscsi": &api.Pod{},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"../examples/glusterfs/v1beta3": {
 | 
							"../examples/glusterfs": {
 | 
				
			||||||
			"glusterfs": &api.Pod{},
 | 
								"glusterfs-pod":       &api.Pod{},
 | 
				
			||||||
 | 
								"glusterfs-endpoints": &api.Endpoints{},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		"../examples": {
 | 
							"../examples": {
 | 
				
			||||||
			"pod":         &api.Pod{},
 | 
								"pod":         &api.Pod{},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,15 +2,45 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[Glusterfs](http://www.gluster.org) is an open source scale-out filesystem. These examples provide information about how to allow 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 assumes that the Glusterfs client package is installed on all nodes.
 | 
					The example assumes that you have already set up a Glusterfs server cluster and the Glusterfs client package is installed on all Kubernetes nodes.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Prerequisites
 | 
					### Prerequisites
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Install Glusterfs client package on the Kubernetes hosts.
 | 
					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
 | 
				
			||||||
 | 
					Here is a snippet of glusterfs-endpoints.json,
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					      "addresses": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "IP": "10.240.106.152"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "ports": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "port": 1,
 | 
				
			||||||
 | 
					          "protocol": "TCP"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					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. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Create the endpoints,
 | 
				
			||||||
 | 
					```shell
 | 
				
			||||||
 | 
					$ kubectl create -f examples/glusterfs/glusterfs-endpoints.json
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You can verify that the endpoints are successfully created by running
 | 
				
			||||||
 | 
					```shell
 | 
				
			||||||
 | 
					$ kubect get endpoints
 | 
				
			||||||
 | 
					NAME                ENDPOINTS
 | 
				
			||||||
 | 
					glusterfs-cluster   10.240.106.152:1,10.240.79.157:1
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Create a POD
 | 
					### Create a POD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The following *volume* spec illustrates a sample configuration.
 | 
					The following *volume* spec in glusterfs-pod.json illustrates a sample configuration.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```js
 | 
					```js
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -29,19 +59,24 @@ The parameters are explained as the followings.
 | 
				
			|||||||
- **path** is the Glusterfs volume name. 
 | 
					- **path** is the Glusterfs volume name. 
 | 
				
			||||||
- **readOnly** is the boolean that sets the mountpoint readOnly or readWrite. 
 | 
					- **readOnly** is the boolean that sets the mountpoint readOnly or readWrite. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Detailed POD and Gluster cluster endpoints examples can be found at [v1beta3/](v1beta3/) and [endpoints/](endpoints/)
 | 
					Create a pod that has a container using Glusterfs volume,
 | 
				
			||||||
 | 
					 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
# create gluster cluster endpoints
 | 
					$ kubectl create -f examples/glusterfs/glusterfs-pod.json
 | 
				
			||||||
$ 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:
 | 
					You can verify that the pod is running:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```shell
 | 
					```shell
 | 
				
			||||||
$ kubectl get endpoints
 | 
					 | 
				
			||||||
$ kubectl get pods
 | 
					$ kubectl get pods
 | 
				
			||||||
 | 
					POD         IP            CONTAINER(S)   IMAGE(S)              HOST                                  LABELS    STATUS    CREATED          MESSAGE
 | 
				
			||||||
 | 
					glusterfs   10.244.2.13                                        kubernetes-minion-151f/23.236.54.97   <none>    Running   About a minute   
 | 
				
			||||||
 | 
					                          glusterfs      kubernetes/pause                                                      Running   About a minute   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you ssh to that machine, you can run `docker ps` to see the actual pod and `mount` to see if the Glusterfs volume is mounted.
 | 
					You may ssh to the host and run 'mount' to see if the Glusterfs volume is mounted,
 | 
				
			||||||
 | 
					```shell
 | 
				
			||||||
 | 
					$ 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)
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You may also run `docker ps` on the host to see the actual container.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
    "apiVersion": "v1beta1",
 | 
					 | 
				
			||||||
    "id": "glusterfs-cluster",
 | 
					 | 
				
			||||||
    "kind": "Endpoints",
 | 
					 | 
				
			||||||
    "metadata": {
 | 
					 | 
				
			||||||
        "name": "glusterfs-cluster"
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "Endpoints": [
 | 
					 | 
				
			||||||
        "10.16.154.81:0",
 | 
					 | 
				
			||||||
        "10.16.154.82:0",
 | 
					 | 
				
			||||||
        "10.16.154.83:0"
 | 
					 | 
				
			||||||
    ]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										35
									
								
								examples/glusterfs/glusterfs-endpoints.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								examples/glusterfs/glusterfs-endpoints.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "kind": "Endpoints",
 | 
				
			||||||
 | 
					  "apiVersion": "v1beta3",
 | 
				
			||||||
 | 
					  "metadata": {
 | 
				
			||||||
 | 
					    "name": "glusterfs-cluster"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "subsets": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "addresses": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "IP": "10.240.106.152"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "ports": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "port": 1,
 | 
				
			||||||
 | 
					          "protocol": "TCP"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "addresses": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "IP": "10.240.79.157"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					      "ports": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          "port": 1,
 | 
				
			||||||
 | 
					          "protocol": "TCP"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user