CI: VM: switch away from Vagrant to Lima

Unlike the current version of Vagrant, Lima remains FLOSS,
and is easier to debug (at least for myself)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2024-10-08 18:02:12 +09:00
parent b404897ff0
commit 642dde94ed
4 changed files with 60 additions and 72 deletions

45
hack/ci/Vagrantfile vendored
View File

@@ -1,45 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrant box for testing kind with non-Ubuntu
Vagrant.configure("2") do |config|
config.vm.box = "fedora/39-cloud-base"
# https://mirrormanager.fedoraproject.org/mirrors/Fedora/39/x86_64
config.vm.box_url = "https://gsl-syd.mm.fcix.net/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-39-1.5.x86_64.vagrant-virtualbox.box"
# assume some ram is needed for the host environment but very little CPU
memory = 10240
cpus = 3
config.vm.provider :virtualbox do |v|
v.memory = memory
v.cpus = cpus
end
config.vm.provision "install-packages", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
set -eux -o pipefail
# Ensure network-related modules to be loaded
modprobe tap ip_tables iptable_nat ip6_tables ip6table_nat
# The moby-engine package included in Fedora lacks support for rootless,
# So we need to install docker-ce and docker-ce-rootless-extras from the upstream.
curl -fsSL https://get.docker.com | sh
dnf install -y golang-go make kubernetes-client podman docker-ce-rootless-extras
systemctl enable --now docker
# Configuration for rootless: https://kind.sigs.k8s.io/docs/user/rootless/
mkdir -p "/etc/systemd/system/user@.service.d"
cat <<EOF >"/etc/systemd/system/user@.service.d/delegate.conf"
[Service]
Delegate=yes
EOF
systemctl daemon-reload
loginctl enable-linger vagrant
SHELL
end
config.vm.provision "install-kind", type: "shell", run: "once" do |sh|
sh.inline = <<~SHELL
set -eux -o pipefail
git config --global --add safe.directory /vagrant
make -C /vagrant install INSTALL_DIR=/usr/local/bin
SHELL
end
end

18
hack/ci/init-fedora.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -eux -o pipefail
# Ensure network-related modules to be loaded
modprobe tap ip_tables iptable_nat ip6_tables ip6table_nat
# The moby-engine package included in Fedora lacks support for rootless,
# So we need to install docker-ce and docker-ce-rootless-extras from the upstream.
curl -fsSL https://get.docker.com | sh
dnf install -y golang-go make kubernetes-client podman docker-ce-rootless-extras
systemctl enable --now docker
# Configuration for rootless: https://kind.sigs.k8s.io/docs/user/rootless/
mkdir -p "/etc/systemd/system/user@.service.d"
cat <<EOF >"/etc/systemd/system/user@.service.d/delegate.conf"
[Service]
Delegate=yes
EOF
systemctl daemon-reload

View File

@@ -15,14 +15,10 @@
set -o errexit -o nounset -o pipefail
: "${LIMA_INSTANCE:=default}"
: "${KIND_EXPERIMENTAL_PROVIDER:=docker}"
SSH_CONFIG=".vagrant/ssh-config"
if [ ! -f "$SSH_CONFIG" ]; then
vagrant ssh-config > "$SSH_CONFIG"
fi
if [ "$ROOTLESS" = "rootless" ]; then
exec ssh -F "$SSH_CONFIG" default KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}"
exec ssh "lima-${LIMA_INSTANCE}" KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}"
fi
exec ssh -F "$SSH_CONFIG" default sudo KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}"
exec ssh "lima-${LIMA_INSTANCE}" sudo KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER" "${@}"