diff options
author | zhichaozhu <zhichao.zhu8@gmail.com> | 2018-05-05 17:23:02 +0800 |
---|---|---|
committer | Forrest Zhu <zhichao.zhu8@gmail.com> | 2018-06-05 07:58:25 +0000 |
commit | 09db9c1968ed9586078d193b16e226553754dd92 (patch) | |
tree | 4abcc54a0e802356adf92f528c8b9b1c222db685 | |
parent | c9bd8b778c698a9fd39764fa0f4275614ecee5a8 (diff) |
use contrail-ansible-deployer to integrate opencontrail into k8s
Change-Id: If78430a159e13cf9456b9985d923a8ec107dc7cc
Signed-off-by: Forrest Zhu <zhichao.zhu8@gmail.com>
10 files changed, 289 insertions, 4 deletions
diff --git a/deploy/adapters/ansible/kubernetes/ansible-kubernetes.yml b/deploy/adapters/ansible/kubernetes/ansible-kubernetes.yml index 68dec5c2..094c6488 100755 --- a/deploy/adapters/ansible/kubernetes/ansible-kubernetes.yml +++ b/deploy/adapters/ansible/kubernetes/ansible-kubernetes.yml @@ -35,7 +35,10 @@ remote_user: root max_fail_percentage: 0 roles: - - kargo + - role: kargo + when: opencontrail is not defined + - role: install-k8s-opencontrail + when: opencontrail is defined and opencontrail == "Enable" - hosts: kube_master remote_user: root diff --git a/deploy/compass_conf/flavor/kubernetes.conf b/deploy/compass_conf/flavor/kubernetes.conf index e7e8ffc8..2e808a83 100755 --- a/deploy/compass_conf/flavor/kubernetes.conf +++ b/deploy/compass_conf/flavor/kubernetes.conf @@ -4,8 +4,6 @@ FLAVORS = [{ 'display_name': 'ansible-kubernetes', 'template': 'ansible-kubernetes.tmpl', 'roles': [ - 'kube_master', 'etcd', 'kube_node', 'ha', 'storage_master', 'storage_node' + 'kube_master', 'etcd', 'kube_node', 'ha', 'storage_master', 'storage_node', 'opencontrail' ], }] - - diff --git a/deploy/compass_conf/role/kubernetes_ansible.conf b/deploy/compass_conf/role/kubernetes_ansible.conf index 3e79cbb9..87bbaf56 100755 --- a/deploy/compass_conf/role/kubernetes_ansible.conf +++ b/deploy/compass_conf/role/kubernetes_ansible.conf @@ -12,6 +12,10 @@ ROLES = [{ 'display_name': 'kube node', 'description': 'kube Node' }, { + 'role': 'opencontrail', + 'display_name': 'opencontrail node', + 'description': 'opencontrail node' +},{ 'role': 'ha', 'display_name': 'ha', 'description': 'ha' diff --git a/deploy/conf/vm_environment/k8-ocl-nofeature-noha.yml b/deploy/conf/vm_environment/k8-ocl-nofeature-noha.yml new file mode 100644 index 00000000..fd7bfda0 --- /dev/null +++ b/deploy/conf/vm_environment/k8-ocl-nofeature-noha.yml @@ -0,0 +1,27 @@ +############################################################################## +# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +--- +TYPE: virtual +FLAVOR: cluster + +plugins: + - opencontrail: "Enable" + +hosts: + - name: host1 + roles: + - kube_master + - etcd + - opencontrail + - ha + + - name: host2 + roles: + - kube_node diff --git a/plugins/opencontrail/plugin.desc b/plugins/opencontrail/plugin.desc new file mode 100644 index 00000000..82ccd5ee --- /dev/null +++ b/plugins/opencontrail/plugin.desc @@ -0,0 +1,43 @@ +# Plugin for opencontrail service for Compass4nfv. +# opencontrail provides a sdn network for k8s. +# +# More details can be found in the development document. +# ############################################################## +--- +plugin: + # plugin name,it is also as the switch to enable/disable plugin in scenario + # files + name: opencontrail + + description: provide a sdn solution for k8s + + maintainers: + + # host os type: centos + os_version: centos + + # true: this plugin is deployed separately on a new node + # false: this plugin is deployed on controller or compute node + independent_hosts: false + + # artifact: package download url for this plugin + artifacts: + url: + + # orchestration + # A plugin can have mutiple components, each component may need to be + # installed on different inventory or have its own configuration. + # due to Compass4nfv currently only supports ansible, so each component + # of the installation and configuration script need to be use ansible. + # cm : congfiguration management tool : only ansible support + # role: each component corresponds to ansible script that locates in the same + # directory as plugin.desc. + # phrase: + # inventory: + orchestration: + cm: ansible + roles: + - role: opencontrail + phrase: post_k8s + inventory: + - localhost diff --git a/plugins/opencontrail/roles/install-k8s-opencontrail/files/bms-instances.yaml b/plugins/opencontrail/roles/install-k8s-opencontrail/files/bms-instances.yaml new file mode 100644 index 00000000..7fb70374 --- /dev/null +++ b/plugins/opencontrail/roles/install-k8s-opencontrail/files/bms-instances.yaml @@ -0,0 +1,32 @@ +--- +provider_config: + bms: + ssh_pwd: root + ssh_user: root + ssh_public_key: /root/.ssh/id_rsa.pub + ssh_private_key: /root/.ssh/id_rsa + domainsuffix: local +instances: + bms1: + provider: bms + roles: + config_database: + config: + control: + analytics_database: + analytics: + webui: + k8s_master: + kubemanager: + ip: 192.16.1.211 + bms2: + provider: bms + roles: + k8s_node: + vrouter: + ip: 192.16.1.212 + +contrail_configuration: + CONTAINER_REGISTRY: opencontrailnightly + CONTRAIL_VERSION: latest + KUBERNETES_CLUSTER_PROJECT: {} diff --git a/plugins/opencontrail/roles/install-k8s-opencontrail/files/kvm-instances.yaml b/plugins/opencontrail/roles/install-k8s-opencontrail/files/kvm-instances.yaml new file mode 100644 index 00000000..b2f9e6dd --- /dev/null +++ b/plugins/opencontrail/roles/install-k8s-opencontrail/files/kvm-instances.yaml @@ -0,0 +1,32 @@ +--- +provider_config: + kvm: + ssh_pwd: root + ssh_user: root + ssh_public_key: /root/.ssh/id_rsa.pub + ssh_private_key: /root/.ssh/id_rsa + domainsuffix: local +instances: + kvm1: + provider: kvm + roles: + config_database: + config: + control: + analytics_database: + analytics: + webui: + k8s_master: + kubemanager: + ip: 10.1.0.50 + kvm2: + provider: kvm + roles: + k8s_node: + vrouter: + ip: 10.1.0.51 + +contrail_configuration: + CONTAINER_REGISTRY: opencontrailnightly + CONTRAIL_VERSION: latest + KUBERNETES_CLUSTER_PROJECT: {} diff --git a/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors.repo b/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors.repo new file mode 100644 index 00000000..4900db69 --- /dev/null +++ b/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors.repo @@ -0,0 +1,32 @@ +[base]
+name=CentOS-$releasever - Base
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
+#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#released updates
+[updates]
+name=CentOS-$releasever - Updates
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
+#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that may be useful
+[extras]
+name=CentOS-$releasever - Extras
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
+#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that extend functionality of existing packages
+[centosplus]
+name=CentOS-$releasever - Plus
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
+#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
diff --git a/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors_aarch64.repo b/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors_aarch64.repo new file mode 100644 index 00000000..1d622d3c --- /dev/null +++ b/plugins/opencontrail/roles/install-k8s-opencontrail/files/mirrors_aarch64.repo @@ -0,0 +1,22 @@ +[base] +name=CentOS-$releasever - Base +baseurl=http://mirror.centos.org/altarch/$releasever/os/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 + +#released updates +[updates] +name=CentOS-$releasever - Updates +baseurl=http://mirror.centos.org/altarch/$releasever/updates/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 + +#additional packages that may be useful +[extras] +name=CentOS-$releasever - Extras +baseurl=http://mirror.centos.org/altarch/$releasever/extras/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 diff --git a/plugins/opencontrail/roles/install-k8s-opencontrail/tasks/main.yml b/plugins/opencontrail/roles/install-k8s-opencontrail/tasks/main.yml new file mode 100644 index 00000000..712ebfa7 --- /dev/null +++ b/plugins/opencontrail/roles/install-k8s-opencontrail/tasks/main.yml @@ -0,0 +1,92 @@ +############################################################################## +# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +--- +- name: clean local repo conf + file: + path: /etc/yum.repos.d + state: absent + run_once: "True" + when: ansible_os_family == 'RedHat' + +- name: create local repo conf dir + file: + path: /etc/yum.repos.d + state: directory + run_once: "True" + when: ansible_os_family == 'RedHat' + +- name: configure local mirror repo + copy: + src: "{{ item }}" + dest: /etc/yum.repos.d/mirrors.repo + with_first_found: + - mirrors_{{ ansible_architecture }}.repo + - mirrors.repo + run_once: "True" + when: ansible_os_family == 'RedHat' + +- name: clean local pip conf to use official pip repo + file: + path: /root/.pip/pip.conf + state: absent + run_once: "True" + +- name: install dependency for ansible update + yum: + name: "{{ item }}" + state: latest + with_items: + - git + - libffi-devel + - openssl-devel + - python-devel + run_once: "True" + when: ansible_os_family == 'RedHat' + +- name: update python packages + pip: + name: "{{ item }}" + state: latest + with_items: + - netaddr + - jinja2 + +- name: git clone contrail-ansible-deployer repo + shell: | + rm -rf /opt/contrail-ansible-deployer + git clone https://github.com/Juniper/contrail-ansible-deployer.git \ + /opt/contrail-ansible-deployer + +- name: copy overrided variables + copy: + src: "{{ item }}" + dest: /opt/contrail-ansible-deployer/config/instances.yaml + with_first_found: + - kvm-instances.yaml + +- name: do not restart network + shell: | + cd /opt/contrail-ansible-deployer + sed -i '9, 13d' playbooks/roles/configure_instances/tasks/RedHat.yml + +- name: run config playbook + shell: | + cd /opt/contrail-ansible-deployer + ansible-playbook -i inventory/ playbooks/configure_instances.yml \ + -b -v 2>&1 | tee config-contrail.log + tags: + - ansible + +- name: run install playbook + shell: | + cd /opt/contrail-ansible-deployer + ansible-playbook -e orchestrator=kubernetes -i inventory/ playbooks/install_contrail.yml \ + -b -v 2>&1 | tee install-contrail.log + tags: + - ansible |