e3b0174e14d4b176687d01af94b1c1334be8be60
[stor4nfv.git] / tutorials / csi-plugin.md
1 ## Prerequisite ##\r
2 \r
3 ### ubuntu\r
4 * Version information\r
5 \r
6         ```\r
7         root@proxy:~# cat /etc/issue\r
8         Ubuntu 16.04.2 LTS \n \l\r
9         ```\r
10 \r
11 ### docker\r
12 * Version information\r
13 \r
14         ```\r
15         root@proxy:~# docker version\r
16         Client:\r
17          Version:      1.12.6\r
18          API version:  1.24\r
19          Go version:   go1.6.2\r
20          Git commit:   78d1802\r
21          Built:        Tue Jan 31 23:35:14 2017\r
22          OS/Arch:      linux/amd64\r
23         \r
24         Server:\r
25          Version:      1.12.6\r
26          API version:  1.24\r
27          Go version:   go1.6.2\r
28          Git commit:   78d1802\r
29          Built:        Tue Jan 31 23:35:14 2017\r
30          OS/Arch:      linux/amd64\r
31         ```\r
32 \r
33 ### [kubernetes](https://github.com/kubernetes/kubernetes) local cluster\r
34 * You can startup the lastest k8s local cluster by executing commands blow:\r
35 \r
36         ```\r
37         cd $HOME\r
38         git clone https://github.com/kubernetes/kubernetes.git\r
39         cd $HOME/kubernetes\r
40         make\r
41         echo alias kubectl='$HOME/kubernetes/cluster/kubectl.sh' >> /etc/profile\r
42         ALLOW_PRIVILEGED=true FEATURE_GATES=CSIPersistentVolume=true,MountPropagation=true RUNTIME_CONFIG="storage.k8s.io/v1alpha1=true" LOG_LEVEL=5 hack/local-up-cluster.sh\r
43         ```\r
44 \r
45 ### [opensds](https://github.com/opensds/opensds) local cluster\r
46 * 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```.\r
47 \r
48 ## Testing steps ##\r
49 \r
50 * Change the workplace\r
51 \r
52         ```\r
53         cd /opt/opensds-k8s-v0.1.0-linux-amd64\r
54         ```\r
55 \r
56 * Configure opensds endpoint IP\r
57 \r
58         ```\r
59         vim csi/deploy/kubernetes/csi-configmap-opensdsplugin.yaml\r
60         ```\r
61 \r
62         The IP (127.0.0.1) should be replaced with the opensds actual endpoint IP.\r
63         ```yaml\r
64         kind: ConfigMap\r
65         apiVersion: v1\r
66             metadata:\r
67         name: csi-configmap-opensdsplugin\r
68             data:\r
69             opensdsendpoint: http://127.0.0.1:50040\r
70         ```\r
71 \r
72 * Create opensds CSI pods.\r
73 \r
74         ```\r
75         kubectl create -f csi/deploy/kubernetes\r
76         ```\r
77 \r
78         After this three pods can be found by ```kubectl get pods``` like below:\r
79 \r
80         - csi-provisioner-opensdsplugin\r
81         - csi-attacher-opensdsplugin\r
82         - csi-nodeplugin-opensdsplugin\r
83 \r
84         You can find more design details from\r
85     [CSI Volume Plugins in Kubernetes Design Doc](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/container-storage-interface.md)\r
86 \r
87 * Create example nginx application\r
88 \r
89         ```\r
90         kubectl create -f csi/examples/kubernetes/nginx.yaml\r
91         ```\r
92 \r
93         This example will mount a opensds volume into ```/var/lib/www/html```.\r
94 \r
95         You can use the following command to inspect into nginx container to verify it.\r
96 \r
97         ```\r
98         docker exec -it <nginx container id> /bin/bash\r
99         ```\r
100 \r
101 ## Clean up steps ##\r
102 \r
103 Clean up example nginx application and opensds CSI pods by the following commands.\r
104 \r
105 ```\r
106 kubectl delete -f csi/examples/kubernetes/nginx.yaml\r
107 kubectl delete -f csi/deploy/kubernetes\r
108 ```\r