2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 KUBEEDGE_SRC="$GOPATH/src/github.com/kubeedge/kubeedge"
13 KUBEEDGE_BIN="$GOPATH/src/github.com/kubeedge/kubeedge/keadm"
14 VERIFY_K8S="$PATH_OF_ELIOTFOLDER/blueprints/uCPE/scripts/verifyk8s.sh"
16 { set +x; } > /dev/null 2>&1
20 if [ "$1" != "--help" ]; then
22 echo "Usage of the command is wrong.. Please type ./kubeedge_setup.sh --help for more details"
29 if [ "$1" == "--help" ]; then
31 echo "This script will setup the kubeedge installation on Eliot master and Eliot edge"
32 echo "Before Executing this, add Eliot master and Eliot edge details in config_kubeedge file"
37 # take_keedge will download the source code of kubeedge in master and in edge
42 git clone https://github.com/kubeedge/kubeedge.git \
48 source config_kubeedge > /dev/null 2>&1
50 common_steps="echo $GOPATH && \
51 git clone https://github.com/kubeedge/kubeedge.git $KUBEEDGE_SRC && \
52 source ~/.profile && \
54 sudo chmod -R 777 github.com && \
58 edge_start="cd $KUBEEDGE_BIN && \
59 sudo chmod +x keadm && \
60 sudo ./keadm join --edgecontrollerip=$MASTERNODEIP --edgenodeid=$EDGENODEID \
61 --k8sserverip=$MASTERNODEIP:8080"
63 # Initialisation of ELIOT master with kubeedge
65 execute_keedge_controller(){
71 # Initialisation of Eliot edge with kubeedge
75 cd $PATH_OF_ELIOTFOLDER/blueprints/uCPE/scripts/src
77 sshpass -p ${EDGENODEPASSWORD} \
78 scp $PATH_OF_ELIOTFOLDER/blueprints/uCPE/scripts/src/config_kubeedge \
79 ${EDGENODEUSR}@${EDGENODEIP}:$HOME_EDGENODE
81 sshpass -p ${EDGENODEPASSWORD} ssh ${EDGENODEUSR}@${EDGENODEIP} \
82 source config_kubeedge
84 source config_kubeedge > /dev/null 2>&1
85 sshpass -p ${EDGENODEPASSWORD} \
86 ssh ${EDGENODEUSR}@${EDGENODEIP} ${common_steps}
88 echo "After cloning the code in ELIOT edge node"
89 sshpass -p ${EDGENODEPASSWORD} \
90 scp /etc/kubeedge/certs.tgz ${EDGENODEUSR}@${EDGENODEIP}:$HOME_EDGENODE
92 sshpass -p ${EDGENODEPASSWORD} \
93 ssh ${EDGENODEUSR}@${EDGENODEIP} \
94 sudo tar -xvzf $HOME/certs.tgz --directory /etc/kubeedge
96 sshpass -p ${EDGENODEPASSWORD} \
97 ssh ${EDGENODEUSR}@${EDGENODEIP} ${edge_start}
102 source config_kubeedge > /dev/null 2>&1
106 execute_keedge_controller
108 exec_edge > /dev/null 2>&1
111 sudo kubectl get nodes
113 if [ "$(id -u)" = 0 ]; then
114 echo "export KUBECONFIG=/etc/kubernetes/admin.conf" | \
115 tee -a "${HOME}/.profile"
116 source "${HOME}/.profile"
118 mkdir -p "${HOME}/.kube"
119 sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
120 sudo chown "$(id -u)":"$(id -g)" "${HOME}/.kube/config"