Setup Kubeedge script on x86
[eliot.git] / scripts / src / kubeedge_setup.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
4 #
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 ##############################################################################
10
11 take_keedge(){
12
13    git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge
14    cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
15    make
16
17 }
18
19 common_steps="git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge &&\
20 cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm &&\
21 make &&\
22 chmod +x kubeedge"
23
24 certif_copy="cd /etc/kubeedge &&\
25 scp certs.tar.gz"
26
27 edge_start="kubeedge join --edgecontrollerip=${nodeip} --edgenodeid=eliot_edge_01"
28
29 execute_keedge_controller(){
30    cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
31    sudo chmod +x kubeedge
32    ./kubeedge init
33 }
34
35
36 # start
37
38 take_keedge
39
40 execute_keedge_controller
41
42 while read line
43 do
44     nodeinfo="${line}"
45     nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
46     nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
47     nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
48     masternodeip=$(echo ${nodeinfo} | cut -d"|" -f3)
49
50     sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${common_steps} < /dev/null
51     sshpass -p ${nodepaswd} scp /etc/kubeedge/certs.tar.gz ${nodeusr}@${nodepaswd}:/etc/kubeedge
52
53     sshpass -p ${nodepaswd} \
54     tar -xvzf /etc/kubeedge/certs.tgz
55
56     sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} kubeedge join --edgecontrollerip=${masternodeip} --edgenodeid=eliot_edge_01 \
57     --k8sserverip=${masternodeip}:8080
58 done < nodelist
59
60 kubectl get nodes
61
62 kubectl create -f deployment.yaml
63
64 kubectl get pods