Last active
October 16, 2020 11:38
-
-
Save gabrik/24e664ff772837563acd59108bc724e5 to your computer and use it in GitHub Desktop.
prepare k3s node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt update && sudo apt upgrade -y | |
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common sshpass -y | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo apt-key fingerprint 0EBFCD88 | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get install docker-ce docker-ce-cli containerd.io -y | |
sudo usermod -aG docker $(whoami) | |
sudo docker image pull nginx:alpine | |
sshpass -p "ato" ssh -o StrictHostKeyChecking=no [email protected] "sudo cat /var/lib/rancher/k3s/server/node-token" > /tmp/k3s-token | |
wget https://gist.githubusercontent.com/gabrik/87d4ae5dadb262709ccaedd5880bb031/raw/44efb4c30a8d020fe20960c76a0b441722e57122/stat.pl -O /home/ubuntu/stat.pl | |
chmod +x /home/ubuntu/stat.pl | |
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.86.2:6443 K3S_TOKEN=$(cat /tmp/k3s-token) sh - | |
export MYIP=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}') | |
sshpass -p "ato" ssh -o StrictHostKeyChecking=no [email protected] "echo $HOSTNAME,$MYIP >> /home/ato/gb/paper/k3s-nodes.csv" | |
sshpass -p "ato" ssh -o StrictHostKeyChecking=no [email protected] "cat ~/.ssh/id_rsa.pub" >> /home/ubuntu/.ssh/authorized_keys | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment