6cfc2c388c37303ba5c0db6051a052e80ba4f84b
[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    source ~/.profile
15    cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
16    make
17    #kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
18    #kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
19 }
20
21 source config_kubeedge
22 common_steps="git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge && \
23 source ~/.profile && \
24 cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm && \
25 make && \
26 chmod +x kubeedge"
27
28 certif_copy="cd /etc/kubeedge &&\
29 scp certs.tar.gz"
30
31 edge_start="cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm && \
32 chmod +x kubeedge && \
33 ./kubeedge join --edgecontrollerip=$masternodeip --edgenodeid=eliotedge02 --k8sserverip=$masternodeip:8080"
34
35 execute_keedge_controller(){
36    cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
37    sudo chmod +x kubeedge
38    ./kubeedge init
39 }
40
41
42 exec_edge(){
43
44    cd $HOME/eliot/scripts/src
45    sshpass -p ${edgenodepassword} scp $HOME/release/eliot/scripts/src/config_kubeedge ${edgenodeusr}@${edgenodeip}:/root
46
47    sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} \
48    source config_kubeedge
49    
50    source config_kubeedge
51    sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} ${common_steps} < /dev/null
52 echo "after common_steps"
53    sshpass -p ${edgenodepassword} scp /etc/kubeedge/certs.tgz ${edgenodeusr}@${edgenodeip}:/etc/kubeedge
54
55    sshpass -p ${edgenodepassword} \
56    ssh ${edgenodeusr}@${edgenodeip} \
57    tar -xvzf /etc/kubeedge/certs.tgz --directory /etc/kubeedge
58    
59    sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} ${edge_start} < /dev/null
60 }
61
62 # start
63
64 source config_kubeedge
65 #sample
66 #return
67 take_keedge
68
69 execute_keedge_controller
70
71 #sample
72 #execute_edge
73 exec_edge
74 kubectl get nodes
75
76 kubectl create -f deployment.yaml
77
78 kubectl get pods