--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# constants
+
+TESTYAML="testk8s-nginx.yaml"
+
+# start
+
+source ../src/config_kubeedge
+cd
+kubectl delete -f $TESTYAML
+
+sshpass -p ${EDGENODEPASSWORD} \
+scp ${PATH_OF_ELIOTFOLDER}/scripts/ci_management/cleanup_edge.sh \
+${EDGENODEUSR}@${EDGENODEIP}:$HOME_EDGENODE
+
+sshpass -p ${EDGENODEPASSWORD} ssh ${EDGENODEUSR}@${EDGENODEIP} \
+source cleanup_edge.sh
+
+cd $PATH_OF_ELIOTFOLDER/scripts/ci_management
+source cleanup_master.sh
+
+sshpass -p ${EDGENODEPASSWORD} \
+scp ${PATH_OF_ELIOTFOLDER}/scripts/ci_management/cleanup_edge_final.sh \
+${EDGENODEUSR}@${EDGENODEIP}:$HOME_EDGENODE
+
+sshpass -p ${EDGENODEPASSWORD} ssh ${EDGENODEUSR}@${EDGENODEIP} \
+source cleanup_edge_final.sh
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# constants
+
+NGINX=$(sudo docker ps | grep nginx | wc -l)
+KUBEPROXY=$(sudo docker ps | grep k8s.gcr.io | wc -l)
+CONSTZERO="0"
+
+# start
+
+source config_kubeedge
+source ~/.profile
+
+cd
+
+if [ -d "/root/go/src/github.com/kubeedge/kubeedge/keadm" ]; then
+ cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
+ ./kubeedge reset --k8sserverip $MASTERNODEIP:8080
+fi
+
+cd /etc/kubeedge
+
+if [ -f "certs.tgz" ]; then
+ sudo rm -rf certs.tgz
+fi
+
+if [ -d "/etc/kubeedge/ca" ]; then
+ sudo rm -rf /etc/kubeedge/ca
+fi
+
+if [ -d "/etc/kubeedge/certs" ]; then
+ sudo rm -rf /etc/kubeedge/certs
+fi
+
+if [ -d "/root/go/src" ]; then
+ sudo rm -rf /root/go/src
+fi
+
+# stop binaries edge_core
+cd /usr/local/bin
+
+if [ -f "edge_core" ]; then
+ sudo rm edge_core
+fi
+
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# start
-
-kubeedge reset
+# constants
-reset="kubeedge reset --k8sserverip ${masternodeip}:8080"
+NGINX=$(sudo docker ps | grep nginx | wc -l)
+KUBEPROXY=$(sudo docker ps | grep k8s.gcr.io | wc -l)
+CONSTZERO="0"
-while read line
-do
- nodeinfo="${line}"
- nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
- nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
- nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
- masternodeip=$(echo ${nodeinfo} | cut -d"|" -f3)
-
- sshpass -p ${nodepaswd} \
- kubeedge reset --k8sserverip ${masternodeip}:8080
+# start
-done < nodelist
+echo "nginx container stop"
+if [ $NGINX != $CONSTZERO ]; then
+ sudo docker kill $(docker ps -q --filter ancestor=nginx:1.15.12 )
+fi
+echo "kubeproxy container stop"
+if [ $KUBEPROXY != $CONSTZERO ]; then
+ sudo docker kill $(docker ps -q --filter ancestor=k8s.gcr.io/kube-proxy:v1.14.2 )
+fi
+echo "Finished"
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# constants
+
+TESTYAML="testk8s-nginx.yaml"
+SUPERUSER="root"
+value=$(whoami)
+
+# start
+
+# kubeedge reset internally undo the things done by ./kubeedge init
+
+if [ -d "/root/go/src/github.com/kubeedge/kubeedge/keadm" ]; then
+ cd /root/go/src/github.com/kubeedge/kubeedge/keadm
+ ./kubeedge reset
+fi
+
+# delete the previously existing certificates
+
+if [ -d "/etc/kubeedge/ca" ]; then
+ sudo rm -rf /etc/kubeedge/ca
+fi
+
+if [ -d "/etc/kubeedge/certs" ]; then
+ cd /etc/kubeedge
+ sudo rm -rf certs
+fi
+
+cd /etc/kubeedge
+if [ -f "certs.tgz" ]; then
+ sudo rm certs.tgz
+fi
+
+# delete the kubeedge code
+
+if [ -d "/root/go/src" ]; then
+ cd /root/go
+ sudo rm -rf src
+fi
+
+# stop binaries edge_core edgecontroller
+
+cd /usr/local/bin
+
+if [ -f "edge_core" ]; then
+ sudo rm edge_core
+fi
+
+if [ -f "edgecontroller" ]; then
+ sudo rm edgecontroller
+fi
+
+if [ $value != $SUPERUSER ]; then
+ sudo su
+fi
+
+cd
+
+if [ -f $TESTYAML ]; then
+ sudo rm $TESTYAML
+fi
+
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# The script is to stop and remove the prometheus and cadvisor containers from
+# ELIOT Manager and ELIOT Edge Node respectively.
+
+# stop prometheus in ELIOT Manager
+source uninstall_prometheus.sh | tee uninstall_prometheus.log
+
+#stop cadvisor statement executed at ELIOT Edge Node
+stop_cadvisor_atedge="cd AfterRelease1/eliot/scripts/ci_management && source uninstall_cadvisor.sh"
+# Read all the Worker Node details from nodelist file.
+while read line
+do
+ nodeinfo="${line}"
+ nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
+ nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
+ nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
+ sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${stop_cadvisor_atedge}
+done < ../nodelist > /dev/null 2>&1
+
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+#stop cadvisor statement executed at ELIOT Edge Node
+if [ $(sudo docker ps | grep cadvisor | wc -l) -gt 0 ];then
+ sudo docker stop $(sudo docker ps | grep cadvisor | awk '{ print $1 }')
+fi
+
+if [ $(sudo docker ps -a | grep cadvisor | wc -l) -gt 0 ];then
+ sudo docker rm $(sudo docker ps -a | grep cadvisor | awk '{ print $1 }')
+fi
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+# stop prometheus in ELIOT Manager
+
+if [ $(sudo docker ps | grep prometheus | wc -l) -gt 0 ];then
+ echo "Stopping prometheus container id :- $(sudo docker ps | grep prometheus | awk '{ print $1 }')"
+ sudo docker stop $(sudo docker ps | grep prometheus | awk '{ print $1 }')
+fi
+if [ $(sudo docker ps -a | grep prometheus | wc -l) -gt 0 ];then
+ echo "Removing prometheus container id $(sudo docker ps -a | grep prometheus | awk '{ print $1 }')"
+ sudo docker rm $(sudo docker ps -a | grep prometheus | awk '{ print $1 }')
+fi
+
}
+#verify kubernetes setup by deploying nginx server.
+
+verify_k8s_status(){
+ set -o xtrace
+ source verifyk8s.sh | tee verifyk8s.log
+}
+
+install_cadvisor_edge(){
+ set -o xtrace
+ SETUP_CADVISOR_ATEDGE="cd AfterRelease1/eliot/scripts/ && source cadvisorsetup.sh"
+ while read line
+ do
+ nodeinfo="${line}"
+ nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
+ nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
+ nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
+ sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_CADVISOR_ATEDGE} < /dev/null
+ done < nodelist
+}
+
+install_prometheus(){
+set -o xtrace
+source prometheus.sh | tee install_prometheus.log
+}
+
# Start
#
setup_k8smaster
+sleep 20
+verify_k8s_status
+
+install_cadvisor_edge
+sleep 10
+install_prometheus
+sleep 5
+sudo docker ps | grep prometheus
-edgenodeusr="root"
-edgenodeip="10.10.0.54"
-edgenodepassword="Huawei@akraino"
-masternodeusr="root"
-masternodeip="10.10.0.45"
-masternodepassword="Huawei@akraino"
+# edge node user name
+EDGENODEUSR=""
+
+# edge node ip
+EDGENODEIP=""
+
+# edge node password
+EDGENODEPASSWORD=""
+
+# master node user name
+MASTERNODEUSR=""
+
+# master node ip
+MASTERNODEIP=""
+
+# master node password
+MASTERNODEPASSWORD=""
+
+# eliot source code path including eliot folder
+PATH_OF_ELIOTFOLDER=""
+
+# home path of edge node
+HOME_EDGENODE=""
+
+# edgenode id for kubeedge configuration
+EDGENODEID=""
source ~/.profile
cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
make
- #kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
- #kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
}
source config_kubeedge
-common_steps="git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge && \
+
+common_steps="echo $GOPATH && \
+echo $HOME && \
+echo $(whoami) && \
+sudo git clone https://github.com/kubeedge/kubeedge.git $GOPATH/src/github.com/kubeedge/kubeedge && \
source ~/.profile && \
+cd $GOPATH/src && \
+sudo chmod -R 777 github.com && \
cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm && \
-make && \
-chmod +x kubeedge"
-
-certif_copy="cd /etc/kubeedge &&\
-scp certs.tar.gz"
+make"
edge_start="cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm && \
-chmod +x kubeedge && \
-./kubeedge join --edgecontrollerip=$masternodeip --edgenodeid=eliotedge02 --k8sserverip=$masternodeip:8080"
+sudo chmod +x kubeedge && \
+sudo ./kubeedge join --edgecontrollerip=$MASTERNODEIP --edgenodeid=$EDGENODEID --k8sserverip=$MASTERNODEIP:8080"
execute_keedge_controller(){
cd $GOPATH/src/github.com/kubeedge/kubeedge/keadm
./kubeedge init
}
-
exec_edge(){
- cd $HOME/eliot/scripts/src
- sshpass -p ${edgenodepassword} scp $HOME/release/eliot/scripts/src/config_kubeedge ${edgenodeusr}@${edgenodeip}:/root
+ cd $PATH_OF_ELIOTFOLDER/scripts/src
- sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} \
+ sshpass -p ${EDGENODEPASSWORD} \
+ scp $PATH_OF_ELIOTFOLDER/scripts/src/config_kubeedge \
+ ${EDGENODEUSR}@${EDGENODEIP}:$HOME_EDGENODE
+
+ sshpass -p ${EDGENODEPASSWORD} ssh ${EDGENODEUSR}@${EDGENODEIP} \
source config_kubeedge
-
+
source config_kubeedge
- sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} ${common_steps} < /dev/null
-echo "after common_steps"
- sshpass -p ${edgenodepassword} scp /etc/kubeedge/certs.tgz ${edgenodeusr}@${edgenodeip}:/etc/kubeedge
+ sshpass -p ${EDGENODEPASSWORD} \
+ ssh ${EDGENODEUSR}@${EDGENODEIP} ${common_steps} < /dev/null
- sshpass -p ${edgenodepassword} \
- ssh ${edgenodeusr}@${edgenodeip} \
+ echo "After cloning the code in ELIOT edge node"
+ sshpass -p ${EDGENODEPASSWORD} \
+ scp /etc/kubeedge/certs.tgz ${EDGENODEUSR}@${EDGENODEIP}:/etc/kubeedge
+
+ sshpass -p ${EDGENODEPASSWORD} \
+ ssh ${EDGENODEUSR}@${EDGENODEIP} \
tar -xvzf /etc/kubeedge/certs.tgz --directory /etc/kubeedge
-
- sshpass -p ${edgenodepassword} ssh ${edgenodeusr}@${edgenodeip} ${edge_start} < /dev/null
+
+ sshpass -p ${EDGENODEPASSWORD} \
+ ssh ${EDGENODEUSR}@${EDGENODEIP} ${edge_start} < /dev/null
}
# start
source config_kubeedge
-#sample
-#return
+
take_keedge
execute_keedge_controller
-#sample
-#execute_edge
exec_edge
-kubectl get nodes
-kubectl create -f deployment.yaml
+sleep 10
+sudo kubectl get nodes
+
+chmod +x $PATH_OF_ELIOTFOLDER/scripts/verifyk8s.sh
+source $PATH_OF_ELIOTFOLDER/scripts/verifyk8s.sh
-kubectl get pods
--- /dev/null
+#!/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+NGINXDEP=~/testk8s-nginx.yaml
+
+cat <<EOF > "${NGINXDEP}"
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nginx-deployment
+ labels:
+ app: nginx
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: nginx
+ template:
+ metadata:
+ labels:
+ app: nginx
+ spec:
+ containers:
+ - name: nginx
+ image: nginx:1.15.12
+ ports:
+ - containerPort: 80
+ hostPort: 80
+EOF
+
+#check if nginx is already deployed
+if ! kubectl get pods | grep nginx; then
+ kubectl create -f ~/testk8s-nginx.yaml
+fi
+
+#To check whether the deployment is succesesfull
+retry=10
+while [ $retry -gt 0 ]
+do
+ if [ 2 == "$(kubectl get pods | grep -c -e STATUS -e Running)" ]; then
+ break
+ fi
+ ((retry-=1))
+ sleep 10
+done
+[ $retry -gt 0 ] || exit 1