Add nbp-ansible script to deploy opensds northbound plugins
[stor4nfv.git] / tutorials / flexvolume-plugin.md
1 ## Prerequisite ##\r
2 ### ubuntu\r
3 * Version information\r
4 \r
5         ```\r
6         root@proxy:~# cat /etc/issue\r
7         Ubuntu 16.04.2 LTS \n \l\r
8         ```\r
9 ### docker\r
10 * Version information\r
11 \r
12         ```\r
13         root@proxy:~# docker version\r
14         Client:\r
15          Version:      1.12.6\r
16          API version:  1.24\r
17          Go version:   go1.6.2\r
18          Git commit:   78d1802\r
19          Built:        Tue Jan 31 23:35:14 2017\r
20          OS/Arch:      linux/amd64\r
21 \r
22         Server:\r
23          Version:      1.12.6\r
24          API version:  1.24\r
25          Go version:   go1.6.2\r
26          Git commit:   78d1802\r
27          Built:        Tue Jan 31 23:35:14 2017\r
28          OS/Arch:      linux/amd64\r
29         ```\r
30 \r
31 ### [kubernetes](https://github.com/kubernetes/kubernetes) local cluster\r
32 * Version information\r
33         ```\r
34         root@proxy:~# kubectl version\r
35         Client Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.0-beta.0-dirty", GitCommit:"a0fb3baa71f1559fd42d1acd9cbdd8a55ab4dfff", GitTreeState:"dirty", BuildDate:"2017-12-13T09:22:09Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}\r
36         Server Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.0-beta.0-dirty", GitCommit:"a0fb3baa71f1559fd42d1acd9cbdd8a55ab4dfff", GitTreeState:"dirty", BuildDate:"2017-12-13T09:22:09Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}\r
37         ```\r
38 * You can startup the k8s local cluster by executing commands blow:\r
39 \r
40         ```\r
41         cd $HOME\r
42         git clone https://github.com/kubernetes/kubernetes.git\r
43         cd $HOME/kubernetes\r
44         git checkout v1.9.0\r
45         make\r
46         echo alias kubectl='$HOME/kubernetes/cluster/kubectl.sh' >> /etc/profile\r
47         RUNTIME_CONFIG=settings.k8s.io/v1alpha1=true AUTHORIZATION_MODE=Node,RBAC hack/local-up-cluster.sh -O\r
48         ```\r
49 \r
50 \r
51 ### [opensds](https://github.com/opensds/opensds) local cluster\r
52 * For testing purposes you can deploy OpenSDS local cluster referring to ```ansible/README.md```. Besides, you need to deploy opensds flexvolume plugin refering to ```nbp-ansible/README.md```.\r
53 \r
54 ## Testing steps ##\r
55 \r
56 * Create service account, role and bind them.\r
57         ```\r
58         cd /opt/opensds-k8s-linux-amd64/provisioner\r
59         kubectl create -f serviceaccount.yaml\r
60         kubectl create -f clusterrole.yaml\r
61         kubectl create -f clusterrolebinding.yaml\r
62         ```\r
63 \r
64 * Change the opensds endpoint IP in pod-provisioner.yaml\r
65 The IP (192.168.56.106) should be replaced with the OpenSDS osdslet actual endpoint IP.\r
66     ```yaml\r
67     kind: Pod\r
68     apiVersion: v1\r
69     metadata:\r
70       name: opensds-provisioner\r
71     spec:\r
72       serviceAccount: opensds-provisioner\r
73       containers:\r
74         - name: opensds-provisioner\r
75           image: opensdsio/opensds-provisioner\r
76           securityContext:\r
77           args:\r
78             - "-endpoint=http://192.168.56.106:50040" # should be replaced\r
79           imagePullPolicy: "IfNotPresent"\r
80     ```\r
81 \r
82 * Create provisioner pod.\r
83         ```\r
84         kubectl create -f pod-provisioner.yaml\r
85         ```\r
86 \r
87 * You can use the following cammands to test the OpenSDS FlexVolume and Proversioner functions.\r
88 \r
89         ```\r
90         kubectl create -f sc.yaml              # Create StorageClass\r
91         kubectl create -f pvc.yaml             # Create PVC\r
92         kubectl create -f pod-application.yaml # Create busybox pod and mount the block storage.\r
93         ```\r
94 \r
95         Execute the `findmnt|grep opensds` to confirm whether the volume has been provided.\r
96 \r
97 ## Clean up steps ##\r
98 \r
99 ```\r
100 kubectl delete -f pod-application.yaml\r
101 kubectl delete -f pvc.yaml\r
102 kubectl delete -f sc.yaml\r
103 \r
104 kubectl delete -f pod-provisioner.yaml\r
105 kubectl delete -f clusterrolebinding.yaml\r
106 kubectl delete -f clusterrole.yaml\r
107 kubectl delete -f serviceaccount.yaml\r
108 ```