/
Vagrantfile-ubuntu
75 lines (61 loc) · 2.3 KB
/
Vagrantfile-ubuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- 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
# 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
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
SHELL
end
end