Dockerfile.test: add "cri-in-userns" (aka rootless) test stage
The `cri-in-userns` stage is for testing "CRI-in-UserNS", which should be used in conjunction with "Kubelet-in-UserNS": https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2033-kubelet-in-userns-aka-rootless This feature is mostly expected to be used for `kind` and `minikube`. Requires Rootless Docker/Podman/nerdctl with cgroup v2 delegation: https://rootlesscontaine.rs/getting-started/common/cgroup2/ (Rootless Docker/Podman/nerdctl prepares the UserNS, so we do not need to create UserNS by ourselves) Usage: ``` podman build --target cri-in-userns -t cri-in-userns -f contrib/Dockerfile.test . podman run -it --rm --privileged cri-in-userns ``` The stage is tested on CI with Rootless Podman on Fedora 34 on Vagrant. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
27
Vagrantfile
vendored
27
Vagrantfile
vendored
@@ -257,4 +257,31 @@ EOF
|
||||
SHELL
|
||||
end
|
||||
|
||||
# Rootless Podman is used for testing CRI-in-UserNS
|
||||
# (We could use rootless nerdctl, but we are using Podman here because it is available in dnf)
|
||||
config.vm.provision "install-rootless-podman", type: "shell", run: "never" do |sh|
|
||||
sh.upload_path = "/tmp/vagrant-install-rootless-podman"
|
||||
sh.inline = <<~SHELL
|
||||
#!/usr/bin/env bash
|
||||
set -eux -o pipefail
|
||||
# Delegate cgroup v2 controllers to rootless
|
||||
mkdir -p /etc/systemd/system/user@.service.d
|
||||
cat > /etc/systemd/system/user@.service.d/delegate.conf << EOF
|
||||
[Service]
|
||||
Delegate=yes
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
# Install Podman
|
||||
dnf install -y podman
|
||||
# Configure Podman to resolve `golang` to `docker.io/library/golang`
|
||||
mkdir -p /etc/containers
|
||||
cat > /etc/containers/registries.conf <<EOF
|
||||
[registries.search]
|
||||
registries = ['docker.io']
|
||||
EOF
|
||||
# Disable SELinux to allow overlayfs
|
||||
setenforce 0
|
||||
SHELL
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user