From 3b36a81db672afab28ccfffd2b4a24baafe21cd3 Mon Sep 17 00:00:00 2001 From: Claudio Vellage Date: Sat, 5 Nov 2022 06:46:32 +0100 Subject: [PATCH] Allow to set docker default address pool (#1971) * Allow to set docker default address pool * fixup! Allow to set docker default address pool Signed-off-by: Yusuke Kuoka * Revert unnecessary chart ver bump * Update docs for DOCKER_DEFAULT_ADDRESS_POOL_* * Fix the dockerd default address pool scripts to actually work as probably intended * Update the E2E testdata runnerdeployment to accomodate the new docker default addr pool options * Correct default dockerd addr pool doc Signed-off-by: Yusuke Kuoka Co-authored-by: Claudio Vellage Co-authored-by: Yusuke Kuoka --- .../testdata/runnerdeploy.envsubst.yaml | 5 +++++ docs/detailed-docs.md | 22 +++++++++++++++++++ runner/entrypoint-dind-rootless.sh | 4 ++++ runner/entrypoint-dind.sh | 4 ++++ 4 files changed, 35 insertions(+) diff --git a/acceptance/testdata/runnerdeploy.envsubst.yaml b/acceptance/testdata/runnerdeploy.envsubst.yaml index 9d4fe5eb..8430a4ea 100644 --- a/acceptance/testdata/runnerdeploy.envsubst.yaml +++ b/acceptance/testdata/runnerdeploy.envsubst.yaml @@ -69,6 +69,11 @@ spec: value: "${ROLLING_UPDATE_PHASE}" - name: ARC_DOCKER_MTU_PROPAGATION value: "true" + # https://github.com/docker/docs/issues/8663 + - name: DOCKER_DEFAULT_ADDRESS_POOL_BASE + value: "172.17.0.0/12" + - name: DOCKER_DEFAULT_ADDRESS_POOL_SIZE + value: "24" dockerMTU: 1400 diff --git a/docs/detailed-docs.md b/docs/detailed-docs.md index 2ae0d8db..19ab9b1c 100644 --- a/docs/detailed-docs.md +++ b/docs/detailed-docs.md @@ -1582,6 +1582,28 @@ spec: value: "true" ``` +There are a few advanced envvars also that are available only for dind runners: + +```yaml +apiVersion: actions.summerwind.dev/v1alpha1 +kind: RunnerDeployment +metadata: + name: example-runnerdeployment +spec: + template: + spec: + dockerdWithinRunnerContainer: true + image: summerwind/actions-runner-dind + env: + # Sets the respective default-address-pools fields within dockerd daemon.json + # See https://github.com/actions-runner-controller/actions-runner-controller/pull/1971 for more information. + # Also see https://github.com/docker/docs/issues/8663 for the default base/size values in dockerd. + - name: DOCKER_DEFAULT_ADDRESS_POOL_BASE + value: "172.17.0.0/12" + - name: DOCKER_DEFAULT_ADDRESS_POOL_SIZE + value: "24" +``` + ### Using IRSA (IAM Roles for Service Accounts) in EKS > This feature requires controller version => [v0.15.0](https://github.com/actions-runner-controller/actions-runner-controller/releases/tag/v0.15.0) diff --git a/runner/entrypoint-dind-rootless.sh b/runner/entrypoint-dind-rootless.sh index 352ee0ec..668de492 100644 --- a/runner/entrypoint-dind-rootless.sh +++ b/runner/entrypoint-dind-rootless.sh @@ -17,6 +17,10 @@ jq ".\"mtu\" = ${MTU}" /home/runner/.config/docker/daemon.json > /tmp/.daemon.js echo "DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=${MTU}" | sudo tee -a /etc/environment fi +if [ -n "${DOCKER_DEFAULT_ADDRESS_POOL_BASE}" ] && [ -n "${DOCKER_DEFAULT_ADDRESS_POOL_SIZE}" ]; then + jq ".\"default-address-pools\" = [{\"base\": \"${DOCKER_DEFAULT_ADDRESS_POOL_BASE}\", \"size\": ${DOCKER_DEFAULT_ADDRESS_POOL_SIZE}}]" /home/runner/.config/docker/daemon.json > /tmp/.daemon.json && mv /tmp/.daemon.json /home/runner/.config/docker/daemon.json +fi + if [ -n "${DOCKER_REGISTRY_MIRROR}" ]; then jq ".\"registry-mirrors\"[0] = \"${DOCKER_REGISTRY_MIRROR}\"" /home/runner/.config/docker/daemon.json > /tmp/.daemon.json && mv /tmp/.daemon.json /home/runner/.config/docker/daemon.json fi diff --git a/runner/entrypoint-dind.sh b/runner/entrypoint-dind.sh index 6795348d..42c9e56f 100755 --- a/runner/entrypoint-dind.sh +++ b/runner/entrypoint-dind.sh @@ -16,6 +16,10 @@ jq ".\"mtu\" = ${MTU}" /etc/docker/daemon.json > /tmp/.daemon.json && mv /tmp/.d echo "environment=DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=${MTU}" >> /etc/supervisor/conf.d/dockerd.conf fi +if [ -n "${DOCKER_DEFAULT_ADDRESS_POOL_BASE}" ] && [ -n "${DOCKER_DEFAULT_ADDRESS_POOL_SIZE}" ]; then + jq ".\"default-address-pools\" = [{\"base\": \"${DOCKER_DEFAULT_ADDRESS_POOL_BASE}\", \"size\": ${DOCKER_DEFAULT_ADDRESS_POOL_SIZE}}]" /etc/docker/daemon.json > /tmp/.daemon.json && mv /tmp/.daemon.json /etc/docker/daemon.json +fi + if [ -n "${DOCKER_REGISTRY_MIRROR}" ]; then jq ".\"registry-mirrors\"[0] = \"${DOCKER_REGISTRY_MIRROR}\"" /etc/docker/daemon.json > /tmp/.daemon.json && mv /tmp/.daemon.json /etc/docker/daemon.json fi