Skip to content

Commit d202338

Browse files
committed
ci: add test for rootful docker
This is important to run on multi-node Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent b259da8 commit d202338

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

.github/workflows/main.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ jobs:
2020
include:
2121
- lima_template: template://ubuntu-24.04
2222
container_engine: docker
23+
rootful: "false"
24+
- lima_template: template://docker-rootful
25+
container_engine: docker
26+
rootful: "true"
2327
- lima_template: template://ubuntu-24.04
2428
container_engine: nerdctl
29+
rootful: "false"
2530
- lima_template: template://centos-stream-9
2631
container_engine: podman
2732
- lima_template: template://fedora
2833
container_engine: podman
34+
rootful: "false"
2935
uses: ./.github/workflows/reusable-multi-node.yaml
3036
with:
3137
lima_template: ${{ matrix.lima_template }}
3238
container_engine: ${{ matrix.container_engine }}
39+
rootful: ${{ matrix.rootful }}
3340

3441
# TODO: this test should create multiple instances of Usernetes on each of the hosts
3542
multi-node-custom-ports:

.github/workflows/reusable-multi-node.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
description: flannel vxlan port
2020
type: string
2121
default: "8472"
22+
rootful:
23+
description: use rootful mode for a container technology
24+
type: string
25+
default: "false"
2226
etcd_port:
2327
description: etcd service port
2428
type: string
@@ -41,6 +45,7 @@ jobs:
4145
env:
4246
LIMA_TEMPLATE: "${{ inputs.lima_template }}"
4347
CONTAINER_ENGINE: "${{ inputs.container_engine }}"
48+
CONTAINER_ROOTFUL: "${{ inputs.rootful }}"
4449
PORT_KUBE_APISERVER: "${{ inputs.kube_apiserver_port }}"
4550
PORT_FLANNEL: "${{ inputs.flannel_port }}"
4651
PORT_KUBELET: "${{ inputs.kubelet_port }}"

hack/create-cluster-lima.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ for host in host0 host1; do
2424
# Set --plain to minimize Limaism
2525
${LIMACTL} start --plain --network lima:user-v2 --name="${host}" ${LIMACTL_CREATE_ARGS} "${LIMA_TEMPLATE}"
2626
${LIMACTL} copy -r "$(pwd)" "${host}:${guest_home}/usernetes"
27-
${LIMACTL} shell "${host}" sudo CONTAINER_ENGINE="${CONTAINER_ENGINE}" "${guest_home}/usernetes/init-host/init-host.root.sh"
27+
${LIMACTL} shell "${host}" sudo CONTAINER_ENGINE="${CONTAINER_ENGINE}" CONTAINER_ROOTFUL="${CONTAINER_ROOTFUL}" "${guest_home}/usernetes/init-host/init-host.root.sh"
2828
# Terminate the current session so that the cgroup delegation takes an effect. This command exits with status 255 as SSH terminates.
2929
${LIMACTL} shell "${host}" sudo loginctl terminate-user "${USER}" || true
3030
${LIMACTL} shell "${host}" sudo loginctl enable-linger "${USER}"
3131
if [ "${LOCKDOWN_SUDO}" = "1" ]; then
3232
# Lockdown sudo to ensure rootless-ness
3333
${LIMACTL} shell "${host}" sudo sh -euxc 'rm -rf /etc/sudoers.d/*-cloud-init-users'
3434
fi
35-
${LIMACTL} shell "${host}" CONTAINER_ENGINE="${CONTAINER_ENGINE}" "${guest_home}/usernetes/init-host/init-host.rootless.sh"
35+
${LIMACTL} shell "${host}" CONTAINER_ENGINE="${CONTAINER_ENGINE}" CONTAINER_ROOTFUL="${CONTAINER_ROOTFUL}" "${guest_home}/usernetes/init-host/init-host.rootless.sh"
3636
done
3737

3838
SERVICE_PORTS="PORT_KUBE_APISERVER=${PORT_KUBE_APISERVER} PORT_ETCD=${PORT_ETCD} PORT_FLANNEL=${PORT_FLANNEL} PORT_KUBELET=${PORT_KUBELET}"

init-host/init-host.root.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if [ "$(id -u)" != "0" ]; then
77
fi
88

99
: "${CONTAINER_ENGINE:=docker}"
10+
: "${CONTAINER_ROOTFUL:=false}"
1011
script_dir="$(dirname "$0")"
1112

1213
if [ ! -e /etc/systemd/system/user@.service.d/delegate.conf ]; then
@@ -64,8 +65,12 @@ else
6465
apt-get install -y git uidmap make jq
6566
fi
6667

67-
case "${CONTAINER_ENGINE}" in
68-
"docker")
68+
setup_docker() {
69+
if [ "${CONTAINER_ROOTFUL}" = "true" ]; then
70+
echo "Preparing to run docker in default rootful mode."
71+
return
72+
fi
73+
echo "Preparing to run docker in rootless mode."
6974
if ! command -v dockerd-rootless-setuptool.sh >/dev/null 2>&1; then
7075
if grep -q centos /etc/os-release; then
7176
# Works with Rocky and Alma too
@@ -76,6 +81,11 @@ case "${CONTAINER_ENGINE}" in
7681
fi
7782
fi
7883
systemctl disable --now docker
84+
}
85+
86+
case "${CONTAINER_ENGINE}" in
87+
"docker")
88+
setup_docker
7989
;;
8090
"podman")
8191
if ! command -v podman-compose >/dev/null 2>&1; then

init-host/init-host.rootless.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,23 @@ if [ "$(id -u)" == "0" ]; then
77
fi
88

99
: "${CONTAINER_ENGINE:=docker}"
10+
: "${CONTAINER_ROOTFUL:=false}"
1011
: "${XDG_CONFIG_HOME:=${HOME}/.config}"
12+
13+
setup_docker_rootless() {
14+
if [ "${CONTAINER_ROOTFUL}" = "true" ]; then
15+
return
16+
fi
17+
dockerd-rootless-setuptool.sh install || (journalctl --user --since "10 min ago"; exit 1)
18+
}
19+
1120
case "${CONTAINER_ENGINE}" in
1221
"docker")
13-
dockerd-rootless-setuptool.sh install || (journalctl --user --since "10 min ago"; exit 1)
22+
setup_docker_rootless
23+
;;
24+
"docker-rootful")
25+
echo "Skipping rootless install of docker"
26+
CONTAINER_ENGINE="docker"
1427
;;
1528
"nerdctl")
1629
containerd-rootless-setuptool.sh install

0 commit comments

Comments
 (0)