summaryrefslogtreecommitdiffstats
path: root/xci/installer/kubespray/deploy.sh
diff options
context:
space:
mode:
authorwutianwei <wutianwei1@huawei.com>2018-01-08 17:17:17 +0800
committerwutianwei <wutianwei1@huawei.com>2018-01-31 17:15:50 +0800
commitb1b71ac7132ff5ccebcfac8ca2bb2f7540025b13 (patch)
tree7306b59b309d9797849a515f754071a0bc526897 /xci/installer/kubespray/deploy.sh
parent862219cb61d57598029fc3dfe21923ccd00df257 (diff)
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 <wutianwei1@huawei.com>
Diffstat (limited to 'xci/installer/kubespray/deploy.sh')
-rwxr-xr-xxci/installer/kubespray/deploy.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/xci/installer/kubespray/deploy.sh b/xci/installer/kubespray/deploy.sh
new file mode 100755
index 00000000..b04ed781
--- /dev/null
+++ b/xci/installer/kubespray/deploy.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2017 Huawei
+# 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
+##############################################################################
+
+K8_XCI_PLAYBOOKS="$(dirname $(realpath ${BASH_SOURCE[0]}))/playbooks"
+export ANSIBLE_ROLES_PATH=$HOME/.ansible/roles:/etc/ansible/roles:${XCI_PATH}/xci/playbooks/roles
+
+
+#-------------------------------------------------------------------------------
+# Configure localhost
+#-------------------------------------------------------------------------------
+# This playbook
+# - removes directories that were created by the previous xci run
+# - clones opnfv/releng-xci repository
+# - clones kubernetes-incubator/kubespray repository
+# - creates log directory
+#-------------------------------------------------------------------------------
+
+echo "Info: Configuring localhost for kubespray"
+echo "-----------------------------------------------------------------------"
+cd $XCI_PLAYBOOKS
+ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -e XCI_PATH="${XCI_PATH}" \
+ -i ${XCI_FLAVOR_ANSIBLE_FILE_PATH}/inventory/inventory.cfg \
+ configure-localhost.yml
+echo "-----------------------------------------------------------------------"
+echo "Info: Configured localhost for kubespray"
+
+#-------------------------------------------------------------------------------
+# Configure deployment host, opnfv
+#-------------------------------------------------------------------------------
+# This playbook
+# - removes directories that were created by the previous xci run
+# - synchronize opnfv/releng-xci and kubernetes-incubator/kubespray repositories
+# - generates/prepares ssh keys
+# - copies flavor files to be used by kubespray
+# - install packages required by kubespray
+#-------------------------------------------------------------------------------
+echo "Info: Configuring opnfv deployment host for kubespray"
+echo "-----------------------------------------------------------------------"
+cd $K8_XCI_PLAYBOOKS
+ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -e XCI_PATH="${XCI_PATH}" \
+ -i ${XCI_FLAVOR_ANSIBLE_FILE_PATH}/inventory/inventory.cfg \
+ configure-opnfvhost.yml
+echo "-----------------------------------------------------------------------"
+echo "Info: Configured opnfv deployment host for kubespray"
+
+#-------------------------------------------------------------------------------
+# Configure target hosts for kubespray
+#-------------------------------------------------------------------------------
+# This playbook is only run for the all flavors except aio since aio is configured by the configure-opnfvhost.yml
+# This playbook
+# - adds public keys to target hosts
+# - install packages required by kubespray
+# - configures haproxy service
+#-------------------------------------------------------------------------------
+if [ $XCI_FLAVOR != "aio" ]; then
+ echo "Info: Configuring target hosts for kubespray"
+ echo "-----------------------------------------------------------------------"
+ cd $K8_XCI_PLAYBOOKS
+ ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -e XCI_PATH="${XCI_PATH}" \
+ -i ${XCI_FLAVOR_ANSIBLE_FILE_PATH}/inventory/inventory.cfg \
+ configure-targethosts.yml
+ echo "-----------------------------------------------------------------------"
+ echo "Info: Configured target hosts for kubespray"
+fi
+
+echo "Info: Using kubespray to deploy the kubernetes cluster"
+echo "-----------------------------------------------------------------------"
+ssh root@$OPNFV_HOST_IP "cd releng-xci/.cache/repos/kubespray;\
+ ansible-playbook ${XCI_ANSIBLE_VERBOSITY} \
+ -i opnfv_inventory/inventory.cfg cluster.yml -b | tee setup-kubernetes.log"
+scp root@$OPNFV_HOST_IP:~/releng-xci/.cache/repos/kubespray/setup-kubernetes.log \
+ $LOG_PATH/setup-kubernetes.log
+# check the log to see if we have any error
+if grep -q 'failed=1\|unreachable=1' $LOG_PATH/setup-kubernetes.log; then
+ echo "Error: Kubernetes cluster setup failed!"
+ exit 1
+fi
+echo "Info: Kubernetes installation is successfully completed!"