summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwutianwei <wutianwei1@huawei.com>2018-06-08 09:49:36 +0800
committerwutianwei <wutianwei1@huawei.com>2018-06-15 09:28:25 +0800
commit462a29c4f0311b398bfebdcde1c56d0b05c85a6b (patch)
tree816557660440528f55d7b448ccf383a0ca401da8
parenta611041d138a71a87c12d4734e5d1a780852ecc9 (diff)
[clover] Add script to setup k8s
what the script do 1. git clone the XCI repo 2. set variable to deploy k8s how to use run the below command in you teminal ./xci-k8s-setup.sh requirement 1. don't under the root user 2. run sudo without password Change-Id: I5015e12d8d3b0db31285d5e817b3c40d6739ba22 Signed-off-by: wutianwei <wutianwei1@huawei.com>
-rwxr-xr-xxci-k8s-setup.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/xci-k8s-setup.sh b/xci-k8s-setup.sh
new file mode 100755
index 0000000..b08be7a
--- /dev/null
+++ b/xci-k8s-setup.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set -e
+set -x
+
+CLOVER_DIR=`cd ${BASH_SOURCE[0]%/*}/;pwd`
+export CLOVER_DIR
+
+# Set the variable for deploying k8s
+export XCI_FLAVOR=${XCI_FLAVOR:-mini}
+export INSTALLER_TYPE=${INSTALLER_TYPE:-kubespray}
+export DEPLOY_SCENARIO=${DEPLOY_SCENARIO:-k8-flannel-nofeature}
+
+if [[ $(whoami) == "root" ]]; then
+ echo "ERROR: This script should not be run as root!"
+ exit 1
+fi
+
+WORK_DIR=${CLOVER_DIR}/work
+sudo rm -rf $WORK_DIR
+mkdir $WORK_DIR
+
+# If SSH key doesn't exist generate an SSH key in $HOME/.ssh/
+[[ ! -d "$HOME/.ssh/" ]] && mkdir $HOME/.ssh/
+[[ ! -f "$HOME/.ssh/id_rsa" ]] && ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""
+
+sudo apt-get update
+sudo apt-get install git python-pip -y
+
+git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORK_DIR/releng-xci
+
+cd $WORK_DIR/releng-xci/xci
+
+source xci-deploy.sh
+
+MASTER_IP=$(ssh root@$OPNFV_HOST_IP "grep -r server ~/.kube/config | awk '{print \$2}' |awk -F '[:/]' '{print \$4}'")
+echo "----------------------------------------"
+echo "Info: You can login the Kubernetes Cluster master host"
+echo "ssh root@$MASTER_IP"
+echo "----------------------------------------"