create a kubernetes cluster
(a work in progress)
create droplets
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$TOKEN'' \
-d '{"names":["k8s-droplet"],
"size":"s-1vcpu-1gb",
"region":"nyc3",
"image":"ubuntu-22-04-x64",
"vpc_uuid":"omitted_guid"}' \
"https://api.digitalocean.com/v2/droplets"
# fix networking config for forwarding (copied, unverified)
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe -a overlay br_netfilter
# sysctl params required by setup, params persist across reboots
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
# Apply sysctl params without reboot
sudo sysctl --system
arch=$(dpkg --print-architecture)
code=$(. /etc/os-release && echo "$VERSION_CODENAME")
curl -fSsL 'https://download.docker.com/linux/ubuntu/gpg' | gpg --dearmor | tee /etc/apt/keyrings/docker.gpg > /dev/null;
echo "deb [arch=$arch signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $code stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update && apt install docker-ce -y
sed 's/^\(disabled_plugins = \["cri"\]\)$/#\1/' /etc/containerd/config.toml -i # re-enable cri plugin???
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | gpg --dearmor | tee /etc/apt/keyrings/k8s.gpg > /dev/null
echo 'deb [arch=$arch signed-by=/etc/apt/keyrings/k8s.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | \
tee /etc/apt/sources.list.d/k8s.list > /dev/null
apt update && apt install kubeadm -y
. <(kubeadm completion bash)
. <(kubectl completion bash)