Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

require "yaml"
vagrant_root = File.dirname(File.expand_path(__FILE__))
settings = YAML.load_file "#{vagrant_root}/settings.yaml"
Expand Down Expand Up @@ -47,7 +46,8 @@ Vagrant.configure("2") do |config|
"ENVIRONMENT" => settings["environment"],
"KUBERNETES_VERSION" => settings["software"]["kubernetes"],
"KUBERNETES_VERSION_SHORT" => settings["software"]["kubernetes"][0..3],
"OS" => settings["software"]["os"]
"OS" => settings["software"]["os"],
"CONTAINER_RUNTIME" => settings["software"]["container_runtime"]
},
path: "scripts/common.sh"
controlplane.vm.provision "shell",
Expand Down Expand Up @@ -83,7 +83,8 @@ Vagrant.configure("2") do |config|
"ENVIRONMENT" => settings["environment"],
"KUBERNETES_VERSION" => settings["software"]["kubernetes"],
"KUBERNETES_VERSION_SHORT" => settings["software"]["kubernetes"][0..3],
"OS" => settings["software"]["os"]
"OS" => settings["software"]["os"],
"CONTAINER_RUNTIME" => settings["software"]["container_runtime"]
},
path: "scripts/common.sh"
node.vm.provision "shell", path: "scripts/node.sh"
Expand All @@ -95,4 +96,4 @@ Vagrant.configure("2") do |config|
end

end
end
end
66 changes: 51 additions & 15 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,52 @@ EOF
# Apply sysctl params without reboot
sudo sysctl --system

## Install CRIO Runtime

## Install Container Runtime
sudo apt-get update -y
apt-get install -y software-properties-common curl apt-transport-https ca-certificates

curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/ /" |
tee /etc/apt/sources.list.d/cri-o.list

sudo apt-get update -y
sudo apt-get install -y cri-o

sudo systemctl daemon-reload
sudo systemctl enable crio --now
sudo systemctl start crio.service
if [ "${CONTAINER_RUNTIME}" == "cri-o" ]; then
echo "Installing CRI-O runtime..."

curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/prerelease:/main/deb/ /" |
tee /etc/apt/sources.list.d/cri-o.list

sudo apt-get update -y
sudo apt-get install -y cri-o

sudo systemctl daemon-reload
sudo systemctl enable crio --now
sudo systemctl start crio.service

elif [ "${CONTAINER_RUNTIME}" == "containerd" ]; then
echo "Installing containerd runtime..."

# Install containerd
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update -y
sudo apt-get install -y containerd.io

# Configure containerd
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml > /dev/null

# Enable SystemdCgroup
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml

sudo systemctl restart containerd
sudo systemctl enable containerd

else
echo "Unsupported container runtime: ${CONTAINER_RUNTIME}"
exit 1
fi

echo "CRI runtime installed successfully"
echo "Container runtime ${CONTAINER_RUNTIME} installed successfully"

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v$KUBERNETES_VERSION_SHORT/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
Expand All @@ -74,8 +102,16 @@ sudo apt-get update -y
sudo apt-get install -y jq

# Disable auto-update services
sudo apt-mark hold kubelet kubectl kubeadm cri-o

sudo apt-mark hold kubelet kubectl kubeadm
if [ "${CONTAINER_RUNTIME}" == "cri-o" ]; then
sudo apt-mark hold cri-o
elif [ "${CONTAINER_RUNTIME}" == "containerd" ]; then
sudo apt-mark hold containerd
else
Something went wrong when marking the container runtime as held.
exit 1
fi

local_ip="$(ip --json a s | jq -r '.[] | if .ifname == "eth1" then .addr_info[] | if .family == "inet" then .local else empty end else empty end')"
cat > /etc/default/kubelet << EOF
Expand Down
4 changes: 2 additions & 2 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cluster_name: Kubernetes Cluster
# All IPs/CIDRs should be private and allowed in /etc/vbox/networks.conf.
network:
# Worker IPs are simply incremented from the control IP.
control_ip: 10.0.0.10
control_ip: 192.168.56.101
dns_servers:
- 8.8.8.8
- 1.1.1.1
Expand All @@ -32,7 +32,7 @@ nodes:
software:
box: bento/ubuntu-24.04
calico: 3.26.0
# To skip the dashboard installation, set its version to an empty value or comment it out:
container_runtime: "containerd" # Options: cri-o, containerd
dashboard: 2.7.0
kubernetes: 1.31.0-*

Expand Down