--- /dev/null
+#!/bin/bash
+
+# Host user which can log into master and each worker nodes
+HOST_USER=${HOST_USER:-iec}
+
+REPO_URL="https://gerrit.akraino.org/r/iec"
+#log file
+LOG_FILE="kubeadm.log"
+
+
+# Master node IP address
+K8S_MASTER_IP="10.169.36.152"
+
+# HOST_USER's password on Master node
+K8S_MASTERPW="123456"
+
+######################################################
+#
+# K8S_WORKER_GROUP is an array which consists of 2
+# parts. One is k8s worker ip address. The other is
+# the user password.
+#
+######################################################
+K8S_WORKER_GROUP=(
+"10.169.40.106,123456"
+)
+
+
--- /dev/null
+#!/bin/bash
+# Run the functest-kubernetes on master node for checking
+# K8s environments
+set -e
+
+K8S_MASTER_IP=$1
+
+
+if [ -z "${K8S_MASTER_IP}" ]
+then
+ echo "Error:K8S_MASTER_IP is empty."
+ echo "Please input the k8s master ip address."
+ echo "Just as:"
+ echo "./functest.sh 10.1.1.1"
+ exit 1
+fi
+
+
+cat <<EOF > "${HOME}/k8.creds"
+export KUBERNETES_PROVIDER=local
+export KUBE_MASTER_URL=https://${K8S_MASTER_IP}:6443
+export KUBE_MASTER_IP=${K8S_MASTER_IP}
+EOF
+
+mkdir -p "${HOME}/functest/results"
+
+sudo docker run --rm -e DEPLOY_SCENARIO=k8-nosdn-nofeature-noha \
+ -v "${HOME}/k8.creds:/home/opnfv/functest/conf/env_file" \
+ -v "${HOME}/functest/results:/home/opnfv/functest/results" \
+ -v "${HOME}/.kube/config:/root/.kube/config" opnfv/functest-kubernetes-healthcheck:latest \
+ /bin/bash -c 'run_tests -r -t all'
DOCKER_VERSION=18.06.1~ce~3-0~ubuntu
KUBE_VERSION=1.13.0-00
+K8S_CNI_VERSION=0.6.0-00
# Install Docker as Prerequisite
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
+# Minor fix for broken kubernetes-cni dependency in upstream xenial repo
sudo apt install -y \
- kubelet=${KUBE_VERSION} kubeadm=${KUBE_VERSION} kubectl=${KUBE_VERSION}
-sudo apt-mark hold kubelet kubeadm kubectl
+ kubernetes-cni=${K8S_CNI_VERSION} kubelet=${KUBE_VERSION} kubeadm=${KUBE_VERSION} kubectl=${KUBE_VERSION}
+sudo apt-mark hold kubernetes-cni kubelet kubeadm kubectl
#Add extra flags to Kubelet
if ! grep -q -e 'fail-swap-on' /etc/default/kubelet; then
# Displays the help menu.
#
display_help () {
- echo "Usage: $0 [master ip] [worker ip] [user] [password] "
+ echo "Usage:"
echo " "
- echo "There should be an user which will be used to install the "
- echo "corresponding software on master & worker node. This user can "
+ echo "This script can help you to deploy a simple iec testing"
+ echo "environments."
+ echo "Firstly, the master node and worker node information must"
+ echo "be added into config file which will be used for deployment."
+ echo ""
+ echo "Secondly, there should be an user on each node which will be"
+ echo "used to install the corresponding software on master and"
+ echo "worker nodes. At the same time, this user should be enable to"
echo "run the sudo command without input password on the hosts."
echo " "
echo "Example usages:"
- echo " ./startup.sh 10.169.40.171 10.169.41.172 iec 123456"
+ echo " ./startup.sh"
}
#Automatic deploy the K8s environments on Master node
SETUP_MASTER="cd iec/src/foundation/scripts/ && source k8s_master.sh ${K8S_MASTER_IP}"
sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${INSTALL_SOFTWARE}
- sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_MASTER} | tee kubeadm.log
+ sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_MASTER} | tee ${LOG_FILE}
- KUBEADM_JOIN_CMD=$(grep "kubeadm join " ./kubeadm.log)
+ KUBEADM_JOIN_CMD=$(grep "kubeadm join " ./${LOG_FILE})
- #Automatic deploy the K8s environments on Worker node
+
+ #Automatic deploy the K8s environments on each worker-node
SETUP_WORKER="cd iec/src/foundation/scripts/ && source k8s_worker.sh"
- sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} ${INSTALL_SOFTWARE}
- sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/src/foundation/scripts/k8s_worker.sh"
- sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} ${SETUP_WORKER}
+
+ for worker in "${K8S_WORKER_GROUP[@]}"
+ do
+ ip_addr="$(cut -d',' -f1 <<<${worker})"
+ passwd="$(cut -d',' -f2 <<<${worker})"
+ echo "Install & Deploy on ${ip_addr}. password:${passwd}"
+
+ sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} ${INSTALL_SOFTWARE}
+ sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/src/foundation/scripts/k8s_worker.sh"
+ sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} ${SETUP_WORKER}
+
+ done
+
#Deploy etcd & CNI from master node
#There may be more options in future. e.g: Calico, Contiv-vpp, Ovn-k8s ...
}
-PASSWD=${4:-"123456"}
-HOST_USER=${3:-"iec"}
-
-K8S_MASTER_IP=${1:-"10.169.40.171"}
-K8S_MASTERPW=${PASSWD}
-
-K8S_WORKER01_IP=${2:-"10.169.41.172"}
-K8S_WORKERPW=${PASSWD}
-
-REPO_URL="https://gerrit.akraino.org/r/iec"
-LOG_FILE="kubeadm.log"
-
-if [ -f "./${LOG_FILE}" ]; then
- rm "${LOG_FILE}"
-fi
-
#
# Init
#
-if [ $# -lt 4 ]
+if [ $1 == "--help" ] || [ $1 == "-h" ];
then
display_help
exit 0
fi
+# Read the configuration file
+source config
+
+echo "The number of K8s-Workers:${#K8S_WORKER_GROUP[@]}"
+
+rm -f "${LOG_FILE}"
+
deploy_k8s
check_k8s_status