From b1b71ac7132ff5ccebcfac8ca2bb2f7540025b13 Mon Sep 17 00:00:00 2001 From: wutianwei Date: Mon, 8 Jan 2018 17:17:17 +0800 Subject: deploy kubernetes in XCI This commit introduces kubespray into XCI. k8s install currently assumes k8s install and OpenStack install cannot coexist. If XCI_INSTALLER is set to "kubespray" and DEPLOY_SCENARIO is set to "k8-nosdn-nofeature" the xci-deploy.sh would install kubernetes instead of OpenStack. The version of kubernetes is beta release v1.9.0 currently according to the master of kubespray it only support the ubuntu now. Opensuse and centos still need to develop and test. This patch create the directory xci/installer/kubespray, the related files of kubespray would be placed to it. The xci/installer/$installer/playbooks/configure-localhost.yml was moved to xci/playbooks/configure-localhost.yml as a common yaml file. You can modify some parameters according your need in xci/installer/kubespray/files/k8s-cluster.yml to deploy cluster. When deploying kubernetes, it would download the kubespray to releng-xci/.cache/repos/kubespray. If your flavor is Ha, it will download haproxy_server and keepalived to xci/playbook/roles, which setup haproxy service for kubernetes. Change-Id: I24d521a735d7ee85fbe5af8c4def65f37586b843 Signed-off-by: wutianwei --- .../kubespray/playbooks/configure-opnfvhost.yml | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 xci/installer/kubespray/playbooks/configure-opnfvhost.yml (limited to 'xci/installer/kubespray/playbooks/configure-opnfvhost.yml') diff --git a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml new file mode 100644 index 00000000..23f93852 --- /dev/null +++ b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml @@ -0,0 +1,77 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# 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 +############################################################################## +- hosts: opnfv + remote_user: root + vars_files: + - "{{ XCI_PATH }}/xci/var/opnfv.yml" + + tasks: + - name: Load distribution variables + include_vars: + file: "{{ item }}" + with_items: + - "{{ XCI_PATH }}/xci/var/{{ ansible_os_family }}.yml" + - name: Set facts for remote deployment + set_fact: + remote_xci_path: "{{ ansible_env.HOME }}/releng-xci" + remote_xci_flavor_files: "{{ ansible_env.HOME }}/releng-xci/xci/installer/{{ XCI_INSTALLER }}/files/{{ XCI_FLAVOR }}" + remote_xci_playbooks: "{{ ansible_env.HOME }}/releng-xci/xci/playbooks" + + - name: Copy releng-xci to remote host + synchronize: + src: "{{ XCI_PATH }}/" + dest: "{{ remote_xci_path }}" + recursive: yes + delete: yes + + - name: generate SSH keys + shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N "" + args: + creates: /root/.ssh/id_rsa + - name: add id_rsa.pub to authorized_keys + shell: cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys + when: XCI_FLAVOR == 'aio' + - name: fetch public key + fetch: + src: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub" + dest: "{{ XCI_PATH }}/xci/files/authorized_keys" + flat: yes + - name: delete the opnfv_inventory directory + file: + path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory" + state: absent + - name: copy kubespray inventory directory + shell: "cp -rf {{ remote_xci_flavor_files }}/inventory \ + {{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory" + - name: make sure kubespray/opnfv_inventory/group_vars/ exist + file: + path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars" + state: directory + - name: copy k8s_cluster.yml + shell: "cp -rf {{ remote_xci_path }}/xci/installer/kubespray/files/k8s-cluster.yml \ + {{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars" + - name: install dbus and ptyhon-netaddr + apt: + name: "{{item}}" + update_cache: yes + with_items: "{{ kube_require_packages }}" + when: XCI_FLAVOR == 'aio' + - name: pip install ansible + pip: + name: ansible + version: "{{ XCI_KUBE_ANSIBLE_PIP_VERSION }}" + + +- hosts: localhost + remote_user: root + vars_files: + - "{{ XCI_PATH }}/xci/var/opnfv.yml" + tasks: + - name: Append public keys to authorized_keys + shell: "/bin/cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub >> {{ XCI_PATH }}/xci/files/authorized_keys" -- cgit 1.2.3-korg