Created
November 22, 2018 20:16
-
-
Save jhunt/49f1711f2cdc8f5ec0281a8378b298d2 to your computer and use it in GitHub Desktop.
hunternetes - A Kubernetes bootstrap script for Linode
This file contains 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 | |
set -eu | |
useradd jhunt -Nm -c 'James Hunt' -d /home/jhunt -g staff -G staff -s /bin/bash | |
cat >/etc/sudoers.d/staff <<EOF | |
%staff ALL=(ALL:ALL) NOPASSWD:ALL | |
EOF | |
install -d -o jhunt -g staff -m 0700 ~jhunt/.ssh | |
cat >~jhunt/.ssh/authorized_keys <<EOF | |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKF3JPSfD1e92ryLKxYlSlXtDmbUUe0EOalBAJvthCmK jhunt@mac | |
EOF | |
chown jhunt:staff ~jhunt/.ssh/authorized_keys | |
chmod 0600 ~jhunt/.ssh/authorized_keys | |
update-alternatives --set editor $(readlink /etc/alternatives/vim) | |
cat >/etc/ssh/sshd_config <<EOF | |
HostbasedAuthentication no | |
PasswordAuthentication no | |
ChallengeResponseAuthentication no | |
KerberosAuthentication no | |
GSSAPIAuthentication no | |
PubkeyAuthentication yes | |
PermitRootLogin no | |
UsePAM yes | |
X11Forwarding no | |
PrintMotd no | |
AcceptEnv LANG LC_* | |
Subsystem sftp /usr/lib/openssh/sftp-server | |
EOF | |
############################ | |
LOCAL_IP=$(/sbin/ifconfig eth0:1 | awk '/inet / { print $2 }' | sed -e 's/addr://') | |
sudo hostnamectl set-hostname $(echo $LOCAL_IP | awk -F. '{print "k8s-" $1 "-" $2 "-" $3 "-" $4}') | |
sed -i -e '/\bswap\b/d' /etc/fstab | |
swapoff -a | |
apt update && \ | |
apt install -y ebtables ethtool \ | |
apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt update && apt install -y docker-ce | |
usermod -aG docker jhunt | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
echo 'deb http://apt.kubernetes.io/ kubernetes-xenial main' | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
apt update && apt install -y kubelet kubeadm kubectl | |
kubeadm init --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address=$LOCAL_IP >/var/log/k8s.log 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment