Skip to content

Instantly share code, notes, and snippets.

@tuxerrante
Created March 2, 2023 15:43
Show Gist options
  • Save tuxerrante/2c3aa0b8f9617b063a8f17c50d2e89d7 to your computer and use it in GitHub Desktop.
Save tuxerrante/2c3aa0b8f9617b063a8f17c50d2e89d7 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2204"
memory = 6144
cpus = 4
config.vm.provider :virtualbox do |v|
v.memory = memory
v.cpus = cpus
end
config.vm.provider :libvirt do |v|
v.memory = memory
v.cpus = cpus
end
config.vm.synced_folder ".", "/vagrant"
config.vm.provision "install-dependencies", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
set -euxo pipefail
# Use a non-localhost DNS to avoid cluster DNS lookup loops
echo "nameserver 8.8.8.8" > /etc/resolv.conf
GO_VERSION=1.20
curl -sSfL -o- https://dl.google.com/go/go"$GO_VERSION".linux-amd64.tar.gz |
tar xfz - -C /usr/local
# Kubernetes
curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update
KUBERNETES_VERSION=1.25.3-00
apt-get install -y \
build-essential \
kubelet=$KUBERNETES_VERSION \
kubeadm=$KUBERNETES_VERSION \
kubectl=$KUBERNETES_VERSION \
podman \
jq \
moreutils \
libbpf-dev \
pkg-config \
lxc-dev \
seccomp \
libseccomp-dev \
apparmor-easyprof apparmor-notify apparmor-utils
# Disable kernel print rate limiting for syslog messaging
sysctl -w kernel.printk_ratelimit=0
sysctl -w kernel.printk_ratelimit_burst=0
podman load -i /vagrant/image.tar
/vagrant/hack/ci/install-cri-o.sh
# Disable IPv6 in bridge plugin config
CNI_CONFIG=/etc/cni/net.d/10-crio-bridge.conf
jq 'del(.ipam.routes[1], .ipam.ranges[1])' $CNI_CONFIG | sponge $CNI_CONFIG
# Setup cluster
IP=`ip route get 1.2.3.4 | cut -d ' ' -f7 | tr -d '[:space:]'`
NODENAME=$(hostname -s)
swapoff -a
modprobe br_netfilter
sysctl -w net.ipv4.ip_forward=1
kubeadm init --apiserver-cert-extra-sans=$IP --node-name $NODENAME
# Setup kubectl
mkdir /home/vagrant/.kube
cp /etc/kubernetes/admin.conf /home/vagrant/.kube/config
chown -R vagrant:vagrant /home/vagrant/.kube
# Configure cluster
export KUBECONFIG=/etc/kubernetes/admin.conf
export PATH=$PATH:/usr/local/go/bin
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
SHELL
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment