summaryrefslogtreecommitdiffstats
path: root/tutorials/csi-plugin.md
blob: e3b0174e14d4b176687d01af94b1c1334be8be60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
## Prerequisite ##

### ubuntu
* Version information

	```
	root@proxy:~# cat /etc/issue
	Ubuntu 16.04.2 LTS \n \l
	```

### docker
* Version information

	```
	root@proxy:~# docker version
	Client:
	 Version:      1.12.6
	 API version:  1.24
	 Go version:   go1.6.2
	 Git commit:   78d1802
	 Built:        Tue Jan 31 23:35:14 2017
	 OS/Arch:      linux/amd64
	
	Server:
	 Version:      1.12.6
	 API version:  1.24
	 Go version:   go1.6.2
	 Git commit:   78d1802
	 Built:        Tue Jan 31 23:35:14 2017
	 OS/Arch:      linux/amd64
	```

### [kubernetes](https://github.com/kubernetes/kubernetes) local cluster
* You can startup the lastest k8s local cluster by executing commands blow:

	```
	cd $HOME
	git clone https://github.com/kubernetes/kubernetes.git
	cd $HOME/kubernetes
	make
	echo alias kubectl='$HOME/kubernetes/cluster/kubectl.sh' >> /etc/profile
	ALLOW_PRIVILEGED=true FEATURE_GATES=CSIPersistentVolume=true,MountPropagation=true RUNTIME_CONFIG="storage.k8s.io/v1alpha1=true" LOG_LEVEL=5 hack/local-up-cluster.sh
	```

### [opensds](https://github.com/opensds/opensds) local cluster
* For testing purposes you can deploy OpenSDS referring the [OpenSDS Cluster Installation through Ansible](https://github.com/opensds/opensds/wiki/OpenSDS-Cluster-Installation-through-Ansible) wiki. Besides, you need to deploy opensds csi plugin refering to ```nbp-ansible/README.md```.

## Testing steps ##

* Change the workplace

	```
	cd /opt/opensds-k8s-v0.1.0-linux-amd64
	```

* Configure opensds endpoint IP

	```
	vim csi/deploy/kubernetes/csi-configmap-opensdsplugin.yaml
	```

	The IP (127.0.0.1) should be replaced with the opensds actual endpoint IP.
	```yaml
	kind: ConfigMap
	apiVersion: v1
	    metadata:
	name: csi-configmap-opensdsplugin
	    data:
	    opensdsendpoint: http://127.0.0.1:50040
	```

* Create opensds CSI pods.

	```
	kubectl create -f csi/deploy/kubernetes
	```

	After this three pods can be found by ```kubectl get pods``` like below:

	- csi-provisioner-opensdsplugin
	- csi-attacher-opensdsplugin
	- csi-nodeplugin-opensdsplugin

	You can find more design details from
    [CSI Volume Plugins in Kubernetes Design Doc](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/container-storage-interface.md)

* Create example nginx application

	```
	kubectl create -f csi/examples/kubernetes/nginx.yaml
	```

	This example will mount a opensds volume into ```/var/lib/www/html```.

	You can use the following command to inspect into nginx container to verify it.

	```
	docker exec -it <nginx container id> /bin/bash
	```

## Clean up steps ##

Clean up example nginx application and opensds CSI pods by the following commands.

```
kubectl delete -f csi/examples/kubernetes/nginx.yaml
kubectl delete -f csi/deploy/kubernetes
```