diff options
author | leonwang <wanghui71@huawei.com> | 2018-01-25 09:01:40 +0000 |
---|---|---|
committer | leonwang <wanghui71@huawei.com> | 2018-01-26 00:23:33 +0000 |
commit | 1dc4e57ae38ea5a4989aeb382c3450a26363ead5 (patch) | |
tree | 514ef1f93a040cde7aeef3406c364f998f54fd19 | |
parent | c032cadb1e645bf60cfd9276ed2660cc602a0e25 (diff) |
Add nbp-ansible script to deploy opensds northbound plugins
In this patch, I created another ansible script to deploy opensds
northbound plugins. Since we plan to integrate opensds with k8s
using flexvolume, I only add flexvolume role to work on it. But
the framework is extensible for adding more roles to integrate
with k8s in other ways.
Besides, I drafted the installation doc of integrating stor4nfv
with k8s in docs directory so that Compass team can work on it
more easily.
Change-Id: Ifbd6cc38bf1789de0fcb132e6aa3cfcd9072a11b
Signed-off-by: leonwang <wanghui71@huawei.com>
-rw-r--r-- | ci/nbp-ansible/README.md | 47 | ||||
-rw-r--r-- | ci/nbp-ansible/clean.yml | 12 | ||||
-rw-r--r-- | ci/nbp-ansible/group_vars/common.yml | 23 | ||||
-rw-r--r-- | ci/nbp-ansible/nbp.hosts | 2 | ||||
-rw-r--r-- | ci/nbp-ansible/roles/cleaner/tasks/main.yml | 21 | ||||
-rw-r--r-- | ci/nbp-ansible/roles/common/tasks/main.yml | 24 | ||||
-rw-r--r-- | ci/nbp-ansible/roles/flexvolume/tasks/main.yml | 11 | ||||
-rw-r--r-- | ci/nbp-ansible/site.yml | 13 | ||||
-rw-r--r-- | tutorials/flexvolume-plugin.md | 108 |
9 files changed, 261 insertions, 0 deletions
diff --git a/ci/nbp-ansible/README.md b/ci/nbp-ansible/README.md new file mode 100644 index 0000000..391bcc3 --- /dev/null +++ b/ci/nbp-ansible/README.md @@ -0,0 +1,47 @@ +# nbp-ansible
+This is an installation tool for opensds northbound plugins using ansible.
+
+## Install work
+
+### Pre-config (Ubuntu 16.04)
+First download some system packages:
+```
+sudo apt-get install -y openssh-server git
+```
+Then config ```/etc/ssh/sshd_config``` file and change one line:
+```conf
+PermitRootLogin yes
+```
+Next generate ssh-token:
+```bash
+ssh-keygen -t rsa
+ssh-copy-id -i ~/.ssh/id_rsa.pub <ip_address> # IP address of the target machine of the installation
+```
+
+### Install docker
+If use a standalone cinder as backend, you also need to install docker to run cinder service. Please see the [docker installation document](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) for details.
+
+### Install ansible tool
+```bash
+sudo add-apt-repository ppa:ansible/ansible # This step is needed to upgrade ansible to version 2.4.2 which is required for the ceph backend.
+sudo apt-get update
+sudo apt-get install ansible
+ansible --version # Ansible version 2.4.2 or higher is required for ceph; 2.0.0.2 or higher is needed for other backends.
+```
+
+### Check if the hosts can be reached
+```bash
+sudo ansible all -m ping -i nbp.hosts
+```
+
+### Run opensds-ansible playbook to start deploy
+```bash
+sudo ansible-playbook site.yml -i nbp.hosts
+```
+
+## Uninstall work
+
+### Run nbp-ansible playbook to clean the environment
+```bash
+sudo ansible-playbook clean.yml -i nbp.hosts
+```
diff --git a/ci/nbp-ansible/clean.yml b/ci/nbp-ansible/clean.yml new file mode 100644 index 0000000..6e5f629 --- /dev/null +++ b/ci/nbp-ansible/clean.yml @@ -0,0 +1,12 @@ +---
+# Defines some clean processes when banishing the cluster.
+
+- name: destory all opensds nbp files
+ hosts: worker-nodes
+ remote_user: root
+ vars_files:
+ - group_vars/common.yml
+ gather_facts: false
+ become: True
+ roles:
+ - cleaner
diff --git a/ci/nbp-ansible/group_vars/common.yml b/ci/nbp-ansible/group_vars/common.yml new file mode 100644 index 0000000..344cab7 --- /dev/null +++ b/ci/nbp-ansible/group_vars/common.yml @@ -0,0 +1,23 @@ +---
+# Variables here are applicable to all host groups NOT roles
+
+# This sample file generated by generate_group_vars_sample.sh
+
+# Dummy variable to avoid error because ansible does not recognize the
+# file as a good configuration file when no variable in it.
+dummy:
+
+# You can override default vars defined in defaults/main.yml here,
+# but I would advice to use host or group vars instead
+
+
+###########
+# GENERAL #
+###########
+
+# These fields are not suggested to be modified
+nbp_download_url: https://github.com/opensds/nbp/releases/download/v0.1.0/opensds-k8s-linux-amd64.tar.gz
+nbp_tarball_url: /opt/opensds-k8s-linux-amd64.tar.gz
+nbp_dir: /opt/opensds-k8s-linux-amd64
+
+flexvolume_plugin_dir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec/opensds.io~opensds
diff --git a/ci/nbp-ansible/nbp.hosts b/ci/nbp-ansible/nbp.hosts new file mode 100644 index 0000000..84d0dc6 --- /dev/null +++ b/ci/nbp-ansible/nbp.hosts @@ -0,0 +1,2 @@ +[worker-nodes]
+localhost ansible_connection=local
\ No newline at end of file diff --git a/ci/nbp-ansible/roles/cleaner/tasks/main.yml b/ci/nbp-ansible/roles/cleaner/tasks/main.yml new file mode 100644 index 0000000..38678b0 --- /dev/null +++ b/ci/nbp-ansible/roles/cleaner/tasks/main.yml @@ -0,0 +1,21 @@ +---
+- name: clean opensds flexvolume plugins binary file
+ file:
+ path: "{{ flexvolume_plugin_dir }}"
+ state: absent
+ force: yes
+ ignore_errors: yes
+
+- name: clean nbp release files
+ file:
+ path: "{{ nbp_dir }}"
+ state: absent
+ force: yes
+ ignore_errors: yes
+
+- name: clean nbp release tarball file
+ file:
+ path: "{{ nbp_tarball_url }}"
+ state: absent
+ force: yes
+ ignore_errors: yes
diff --git a/ci/nbp-ansible/roles/common/tasks/main.yml b/ci/nbp-ansible/roles/common/tasks/main.yml new file mode 100644 index 0000000..b612e24 --- /dev/null +++ b/ci/nbp-ansible/roles/common/tasks/main.yml @@ -0,0 +1,24 @@ +---
+- name: Run the equivalent of "apt-get update" as a separate step
+ apt:
+ update_cache: yes
+
+- name: check for nbp release files existed
+ stat:
+ path: "{{ nbp_dir }}"
+ ignore_errors: yes
+ register: releasesexisted
+
+- name: download nbp release files
+ get_url:
+ url={{ nbp_download_url }}
+ dest={{ nbp_tarball_url }}
+ when:
+ - releasesexisted.stat.exists is undefined or releasesexisted.stat.exists == false
+
+- name: extract the nbp release tarball
+ unarchive:
+ src={{ nbp_tarball_url }}
+ dest=/opt/
+ when:
+ - releasesexisted.stat.exists is undefined or releasesexisted.stat.exists == false
diff --git a/ci/nbp-ansible/roles/flexvolume/tasks/main.yml b/ci/nbp-ansible/roles/flexvolume/tasks/main.yml new file mode 100644 index 0000000..0bba93b --- /dev/null +++ b/ci/nbp-ansible/roles/flexvolume/tasks/main.yml @@ -0,0 +1,11 @@ +---
+- name: Create flexvolume plugin directory if not existed
+ file:
+ path: "{{ flexvolume_plugin_dir }}"
+ state: directory
+ mode: 0755
+
+- name: Copy opensds flexvolume plugin binary file into flexvolume plugin dir
+ copy:
+ src: "{{ nbp_dir }}/flexvolume/opensds"
+ dest: "{{ flexvolume_plugin_dir }}/opensds"
diff --git a/ci/nbp-ansible/site.yml b/ci/nbp-ansible/site.yml new file mode 100644 index 0000000..42c0790 --- /dev/null +++ b/ci/nbp-ansible/site.yml @@ -0,0 +1,13 @@ +---
+# Defines deployment design and assigns role to server groups
+
+- name: deploy opensds flexvolume plugin in all kubelet nodes
+ hosts: worker-nodes
+ remote_user: root
+ vars_files:
+ - group_vars/common.yml
+ gather_facts: false
+ become: True
+ roles:
+ - common
+ - flexvolume
diff --git a/tutorials/flexvolume-plugin.md b/tutorials/flexvolume-plugin.md new file mode 100644 index 0000000..450acd5 --- /dev/null +++ b/tutorials/flexvolume-plugin.md @@ -0,0 +1,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
+* Version information
+ ```
+ root@proxy:~# kubectl version
+ 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"}
+ 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"}
+ ```
+* You can startup the k8s local cluster by executing commands blow:
+
+ ```
+ cd $HOME
+ git clone https://github.com/kubernetes/kubernetes.git
+ cd $HOME/kubernetes
+ git checkout v1.9.0
+ make
+ echo alias kubectl='$HOME/kubernetes/cluster/kubectl.sh' >> /etc/profile
+ RUNTIME_CONFIG=settings.k8s.io/v1alpha1=true AUTHORIZATION_MODE=Node,RBAC hack/local-up-cluster.sh -O
+ ```
+
+
+### [opensds](https://github.com/opensds/opensds) local cluster
+* 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```.
+
+## Testing steps ##
+
+* Create service account, role and bind them.
+ ```
+ cd /opt/opensds-k8s-linux-amd64/provisioner
+ kubectl create -f serviceaccount.yaml
+ kubectl create -f clusterrole.yaml
+ kubectl create -f clusterrolebinding.yaml
+ ```
+
+* Change the opensds endpoint IP in pod-provisioner.yaml
+The IP (192.168.56.106) should be replaced with the OpenSDS osdslet actual endpoint IP.
+ ```yaml
+ kind: Pod
+ apiVersion: v1
+ metadata:
+ name: opensds-provisioner
+ spec:
+ serviceAccount: opensds-provisioner
+ containers:
+ - name: opensds-provisioner
+ image: opensdsio/opensds-provisioner
+ securityContext:
+ args:
+ - "-endpoint=http://192.168.56.106:50040" # should be replaced
+ imagePullPolicy: "IfNotPresent"
+ ```
+
+* Create provisioner pod.
+ ```
+ kubectl create -f pod-provisioner.yaml
+ ```
+
+* You can use the following cammands to test the OpenSDS FlexVolume and Proversioner functions.
+
+ ```
+ kubectl create -f sc.yaml # Create StorageClass
+ kubectl create -f pvc.yaml # Create PVC
+ kubectl create -f pod-application.yaml # Create busybox pod and mount the block storage.
+ ```
+
+ Execute the `findmnt|grep opensds` to confirm whether the volume has been provided.
+
+## Clean up steps ##
+
+```
+kubectl delete -f pod-application.yaml
+kubectl delete -f pvc.yaml
+kubectl delete -f sc.yaml
+
+kubectl delete -f pod-provisioner.yaml
+kubectl delete -f clusterrolebinding.yaml
+kubectl delete -f clusterrole.yaml
+kubectl delete -f serviceaccount.yaml
+```
\ No newline at end of file |