Skip to content

Commit 0010ee9

Browse files
committed
review: add CONTAINER_ROOTFUL
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent 4eaa091 commit 0010ee9

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

.github/workflows/main.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@ jobs:
2020
include:
2121
- lima_template: template://ubuntu-24.04
2222
container_engine: docker
23+
rootful: "false"
2324
- lima_template: template://docker-rootful
24-
container_engine: docker-rootful
25+
container_engine: docker
26+
rootful: "true"
2527
- lima_template: template://ubuntu-24.04
2628
container_engine: nerdctl
29+
rootful: "false"
2730
- lima_template: template://centos-stream-9
2831
container_engine: podman
2932
- lima_template: template://fedora
3033
container_engine: podman
34+
rootful: "false"
3135
uses: ./.github/workflows/reusable-multi-node.yaml
3236
with:
3337
lima_template: ${{ matrix.lima_template }}
3438
container_engine: ${{ matrix.container_engine }}
39+
rootful: ${{ matrix.rootful }}
3540

3641
# TODO: this test should create multiple instances of Usernetes on each of the hosts
3742
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: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ done
3737

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

40-
# At this point, rootless / rootful Docker is setup
41-
if [[ "$CONTAINER_ENGINE" == "docker-rootful" ]]
42-
then
43-
CONTAINER_ENGINE="docker"
44-
fi
45-
4640
# Launch a Kubernetes node inside a Rootless Docker host
4741
for host in host0 host1; do
4842
${LIMACTL} shell "${host}" ${SERVICE_PORTS} CONTAINER_ENGINE="${CONTAINER_ENGINE}" make -C "${guest_home}/usernetes" up

init-host/init-host.root.sh

Lines changed: 12 additions & 5 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,9 +81,11 @@ case "${CONTAINER_ENGINE}" in
7681
fi
7782
fi
7883
systemctl disable --now docker
79-
;;
80-
"docker-rootful")
81-
echo "Preparing to run docker in default rootful mode."
84+
}
85+
86+
case "${CONTAINER_ENGINE}" in
87+
"docker")
88+
setup_docker
8289
;;
8390
"podman")
8491
if ! command -v podman-compose >/dev/null 2>&1; then

init-host/init-host.rootless.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ 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
1423
;;
1524
"docker-rootful")
1625
echo "Skipping rootless install of docker"

0 commit comments

Comments
 (0)