github.com/eth-easl/loader@v0.0.0-20230908084258-8a37e1d94279/scripts/setup/create_singlenode_container.sh (about) 1 #!/usr/bin/env bash 2 # 3 # MIT License 4 # 5 # Copyright (c) 2023 EASL and the vHive community 6 # 7 # Permission is hereby granted, free of charge, to any person obtaining a copy 8 # of this software and associated documentation files (the "Software"), to deal 9 # in the Software without restriction, including without limitation the rights 10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 # copies of the Software, and to permit persons to whom the Software is 12 # furnished to do so, subject to the following conditions: 13 # 14 # The above copyright notice and this permission notice shall be included in all 15 # copies or substantial portions of the Software. 16 # 17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 # SOFTWARE. 24 # 25 26 SERVER=$1 27 28 DIR="$(pwd)/scripts/setup/" 29 30 source "$(pwd)/scripts/setup/setup.cfg" 31 32 server_exec() { 33 ssh -oStrictHostKeyChecking=no -p 22 "$SERVER" $1; 34 } 35 36 { 37 # Spin up vHive under container mode. 38 server_exec 'sudo DEBIAN_FRONTEND=noninteractive apt-get autoremove' 39 server_exec "git clone --branch=$VHIVE_BRANCH https://github.com/ease-lab/vhive" 40 server_exec 'cd vhive; ./scripts/cloudlab/setup_node.sh stock-only' 41 server_exec 'tmux new -s runner -d' 42 server_exec 'tmux new -s kwatch -d' 43 server_exec 'tmux new -d -s containerd' 44 server_exec 'tmux new -d -s cluster' 45 server_exec 'tmux send-keys -t containerd "sudo containerd" ENTER' 46 sleep 3 47 server_exec 'cd vhive; ./scripts/cluster/create_one_node_cluster.sh stock-only' 48 server_exec 'tmux send-keys -t cluster "watch -n 0.5 kubectl get pods -A" ENTER' 49 50 # Update golang. 51 server_exec 'wget -q https://dl.google.com/go/go1.17.linux-amd64.tar.gz' 52 server_exec 'sudo rm -rf /usr/local/go && sudo tar -C /usr/local/ -xzf go1.17.linux-amd64.tar.gz' 53 server_exec 'rm go1.17*' 54 server_exec 'echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile' 55 server_exec 'source ~/.profile' 56 57 # Setup github authentication. 58 ACCESS_TOKEH="$(cat $GITHUB_TOKEN)" 59 60 server_exec 'echo -en "\n\n" | ssh-keygen -t rsa' 61 server_exec 'ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts' 62 # server_exec 'RSA=$(cat ~/.ssh/id_rsa.pub)' 63 64 server_exec 'curl -H "Authorization: token '"$ACCESS_TOKEH"'" --data "{\"title\":\"'"key:\$(hostname)"'\",\"key\":\"'"\$(cat ~/.ssh/id_rsa.pub)"'\"}" https://api.github.com/user/keys' 65 # server_exec 'sleep 5' 66 67 # Get loader and dependencies. 68 server_exec "git clone --branch=$LOADER_BRANCH git@github.com:eth-easl/loader.git" 69 server_exec 'echo -en "\n\n" | sudo apt-get install python3-pip python-dev' 70 server_exec 'cd; cd loader; pip install -r config/requirements.txt' 71 72 $DIR/expose_infra_metrics.sh $SERVER 73 74 # Stabilize the node 75 server_exec './vhive/scripts/stabilize.sh' 76 }