-
-
Save mrlannigan/542ad981fc9b3be9e265c1b10bb3a811 to your computer and use it in GitHub Desktop.
bootstrap-ubuntu-server
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 | |
## Edit sudoers (add "NOPASSWD:" to the sudo line before ALL) | |
## Add optional: true to netplan and apply | |
# Install Docker | |
sudo apt-get update | |
sudo apt-get -y install \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
ioping \ | |
gnupg-agent \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
sudo apt-get update && sudo apt-get install -y \ | |
containerd.io=1.2.13-2 \ | |
docker-ce=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) \ | |
docker-ce-cli=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) | |
sudo apt-mark hold containerd.io docker-ce docker-ce-cli | |
sudo usermod -a -G docker tyzbit | |
# kubeadm | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
deb https://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
sudo apt-get update | |
sudo apt-get install -y kubelet=1.22.12-00 kubeadm=1.22.12-00 kubectl=1.22.12-00 | |
sudo apt-mark hold kubelet kubeadm kubectl | |
# install common tools | |
sudo apt install -y \ | |
fio \ | |
iotop \ | |
jq \ | |
net-tools \ | |
nethogs \ | |
nfs-common \ | |
open-iscsi \ | |
pv \ | |
rename \ | |
screen \ | |
smartmontools \ | |
sysstat | |
## Needed for problematic networking nodes | |
# sudo sysctl net.bridge.bridge-nf-call-iptables=1 | |
# sudo update-alternatives --set iptables /usr/sbin/iptables-legacy | |
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf | |
br_netfilter | |
EOF | |
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.bridge.bridge-nf-call-iptables = 1 | |
EOF | |
sudo sysctl --system | |
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv | |
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv | |
sudo swapoff /swap.img | |
sudo sed -i '/^.*swap.img/s/^/#/' /etc/fstab | |
cat <<EOF | sudo tee /etc/docker/daemon.json | |
{ | |
"exec-opts": ["native.cgroupdriver=systemd"], | |
"log-driver": "json-file", | |
"log-opts": { | |
"max-size": "100m" | |
}, | |
"storage-driver": "overlay2" | |
} | |
EOF | |
sudo mkdir -p /etc/systemd/system/docker.service.d | |
sudo systemctl daemon-reload | |
sudo systemctl restart docker | |
sudo systemctl enable docker | |
# needed for longhorn | |
# https://github.com/longhorn/longhorn/issues/1210#issuecomment-671689746 | |
sudo tee -a /etc/multipath.conf <<EOF | |
blacklist { | |
devnode "^sd[a-z0-9]+" | |
} | |
EOF | |
sudo systemctl restart multipathd.service | |
# wakeonlan | |
interface=$(ifconfig | grep -B1 'broadcast 192.168.1.255' | head -n 1 | awk '{print $1}' | sed 's/://g') | |
cat <<EOF | sudo tee /etc/systemd/system/[email protected] | |
[Unit] | |
Description=Wake-on-LAN for %i | |
Requires=network.target | |
After=network.target | |
[Service] | |
ExecStart=/sbin/ethtool -s %i wol g | |
Type=oneshot | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sudo systemctl enable wol@$interface | |
sudo ethtool -s $interface wol g | |
echo "$(hostname) :: $(ifconfig | grep -A2 'broadcast 192.168.1.255' | tail -n 1 | awk '{print $1,$2}')" | |
#curl http://config.jura:8080/newrelic-logging.sh | bash | |
#sudo curl -o /etc/newrelic-infra/logging.d/syslog.yaml http://config.jura:8080/syslog.yaml | |
#sudo systemctl restart newrelic-infra.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment