feat: expose if docker is enabled and wait for docker to be ready (#962)
Resolves #897 Resolves #915
This commit is contained in:
parent
c5950d75fa
commit
ad48851dc9
|
|
@ -95,6 +95,7 @@ To make your development cycle faster, use the below command to update deploy an
|
|||
# you either need to bump VERSION and RUNNER_TAG on each run,
|
||||
# or manually run `kubectl delete pod $POD` on respective pods for changes to actually take effect.
|
||||
|
||||
# Makefile
|
||||
VERSION=controller1 \
|
||||
RUNNER_TAG=runner1 \
|
||||
make acceptance/pull acceptance/kind docker-build acceptance/load acceptance/deploy
|
||||
|
|
@ -103,14 +104,16 @@ VERSION=controller1 \
|
|||
If you've already deployed actions-runner-controller and only want to recreate pods to use the newer image, you can run:
|
||||
|
||||
```shell
|
||||
# Makefile
|
||||
NAME=$DOCKER_USER/actions-runner-controller \
|
||||
make docker-build acceptance/load && \
|
||||
kubectl -n actions-runner-system delete po $(kubectl -n actions-runner-system get po -ojsonpath={.items[*].metadata.name})
|
||||
```
|
||||
|
||||
Similarly, if you'd like to recreate runner pods with the newer runner image,
|
||||
Similarly, if you'd like to recreate runner pods with the newer runner image you can use the runner specific [Makefile](runner/Makefile) to build and / or push new runner images
|
||||
|
||||
```shell
|
||||
# runner/Makefile
|
||||
NAME=$DOCKER_USER/actions-runner make \
|
||||
-C runner docker-{build,push}-ubuntu && \
|
||||
(kubectl get po -ojsonpath={.items[*].metadata.name} | xargs -n1 kubectl delete po)
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -5,6 +5,7 @@ else
|
|||
endif
|
||||
DOCKER_USER ?= $(shell echo ${NAME} | cut -d / -f1)
|
||||
VERSION ?= latest
|
||||
TARGETPLATFORM ?= $(shell arch)
|
||||
RUNNER_NAME ?= ${DOCKER_USER}/actions-runner
|
||||
RUNNER_TAG ?= ${VERSION}
|
||||
TEST_REPO ?= ${DOCKER_USER}/actions-runner-controller
|
||||
|
|
@ -111,7 +112,7 @@ generate: controller-gen
|
|||
# Build the docker image
|
||||
docker-build:
|
||||
docker build -t ${NAME}:${VERSION} .
|
||||
docker build -t ${RUNNER_NAME}:${RUNNER_TAG} --build-arg TARGETPLATFORM=$(shell arch) runner
|
||||
docker build -t ${RUNNER_NAME}:${RUNNER_TAG} --build-arg TARGETPLATFORM=${TARGETPLATFORM} runner
|
||||
|
||||
docker-buildx:
|
||||
export DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
|
|
|
|||
24
README.md
24
README.md
|
|
@ -28,6 +28,7 @@ ToC:
|
|||
- [Additional Tweaks](#additional-tweaks)
|
||||
- [Runner Labels](#runner-labels)
|
||||
- [Runner Groups](#runner-groups)
|
||||
- [Runner Entrypoint Features](#runner-entrypoint-features)
|
||||
- [Using IRSA (IAM Roles for Service Accounts) in EKS](#using-irsa-iam-roles-for-service-accounts-in-eks)
|
||||
- [Stateful Runners](#stateful-runners)
|
||||
- [Ephemeral Runners](#ephemeral-runners)
|
||||
|
|
@ -1044,6 +1045,29 @@ spec:
|
|||
group: NewGroup
|
||||
```
|
||||
|
||||
### Runner Entrypoint Features
|
||||
|
||||
> Environment variable values must all be strings
|
||||
|
||||
The entrypoint script is aware of a few environment variables for configuring features:
|
||||
|
||||
```yaml
|
||||
apiVersion: actions.summerwind.dev/v1alpha1
|
||||
kind: RunnerDeployment
|
||||
metadata:
|
||||
name: example-runnerdeployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
env:
|
||||
# Issues a sleep command at the start of the entrypoint
|
||||
- name: STARTUP_DELAY_IN_SECONDS
|
||||
value: "2"
|
||||
# Disables the wait for the docker daemon to be available check
|
||||
- name: DISABLE_WAIT_FOR_DOCKER
|
||||
value: "true"
|
||||
```
|
||||
|
||||
### 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)
|
||||
|
|
|
|||
|
|
@ -782,6 +782,8 @@ func newRunnerPod(template corev1.Pod, runnerSpec v1alpha1.RunnerConfig, default
|
|||
dockerRegistryMirror = *runnerSpec.DockerRegistryMirror
|
||||
}
|
||||
|
||||
// Be aware some of the environment variables are used
|
||||
// in the runner entrypoint script
|
||||
env := []corev1.EnvVar{
|
||||
{
|
||||
Name: EnvVarOrg,
|
||||
|
|
@ -803,6 +805,10 @@ func newRunnerPod(template corev1.Pod, runnerSpec v1alpha1.RunnerConfig, default
|
|||
Name: "RUNNER_GROUP",
|
||||
Value: runnerSpec.Group,
|
||||
},
|
||||
{
|
||||
Name: "DOCKER_ENABLED",
|
||||
Value: fmt.Sprintf("%v", dockerEnabled || dockerdInRunner),
|
||||
},
|
||||
{
|
||||
Name: "DOCKERD_IN_RUNNER",
|
||||
Value: fmt.Sprintf("%v", dockerdInRunner),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG RUNNER_VERSION=2.280.3
|
||||
ARG RUNNER_VERSION=2.286.0
|
||||
ARG DOCKER_CHANNEL=stable
|
||||
ARG DOCKER_VERSION=20.10.8
|
||||
ARG DUMB_INIT_VERSION=1.2.5
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG RUNNER_VERSION=2.280.3
|
||||
ARG RUNNER_VERSION=2.286.0
|
||||
ARG DOCKER_CHANNEL=stable
|
||||
ARG DOCKER_VERSION=20.10.8
|
||||
ARG DUMB_INIT_VERSION=1.2.5
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
NAME ?= summerwind/actions-runner
|
||||
DIND_RUNNER_NAME ?= ${NAME}-dind
|
||||
DOCKER_USER ?= summerwind
|
||||
NAME ?= ${DOCKER_USER}/actions-runner
|
||||
DIND_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind
|
||||
TAG ?= latest
|
||||
TARGET_PLATFORM ?= $(shell arch)
|
||||
TARGETPLATFORM ?= $(shell arch)
|
||||
|
||||
RUNNER_VERSION ?= 2.280.3
|
||||
RUNNER_VERSION ?= 2.286.0
|
||||
DOCKER_VERSION ?= 20.10.8
|
||||
|
||||
# default list of platforms for which multiarch image is built
|
||||
|
|
@ -24,8 +25,8 @@ else
|
|||
endif
|
||||
|
||||
docker-build-ubuntu:
|
||||
docker build --build-arg TARGETPLATFORM=${TARGET_PLATFORM} --build-arg RUNNER_VERSION=${RUNNER_VERSION} --build-arg DOCKER_VERSION=${DOCKER_VERSION} -t ${NAME}:${TAG} .
|
||||
docker build --build-arg TARGETPLATFORM=${TARGET_PLATFORM} --build-arg RUNNER_VERSION=${RUNNER_VERSION} --build-arg DOCKER_VERSION=${DOCKER_VERSION} -t ${DIND_RUNNER_NAME}:${TAG} -f Dockerfile.dindrunner .
|
||||
docker build --build-arg TARGETPLATFORM=${TARGETPLATFORM} --build-arg RUNNER_VERSION=${RUNNER_VERSION} --build-arg DOCKER_VERSION=${DOCKER_VERSION} -t ${NAME}:${TAG} .
|
||||
docker build --build-arg TARGETPLATFORM=${TARGETPLATFORM} --build-arg RUNNER_VERSION=${RUNNER_VERSION} --build-arg DOCKER_VERSION=${DOCKER_VERSION} -t ${DIND_RUNNER_NAME}:${TAG} -f Dockerfile.dindrunner .
|
||||
|
||||
docker-push-ubuntu:
|
||||
docker push ${NAME}:${TAG}
|
||||
|
|
@ -39,12 +40,12 @@ docker-buildx-ubuntu:
|
|||
docker buildx build --platform ${PLATFORMS} \
|
||||
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
|
||||
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
|
||||
-t "${NAME}:latest" \
|
||||
-t "${NAME}:${TAG}" \
|
||||
-f Dockerfile \
|
||||
. ${PUSH_ARG}
|
||||
docker buildx build --platform ${PLATFORMS} \
|
||||
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
|
||||
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
|
||||
-t "${DIND_RUNNER_NAME}:latest" \
|
||||
-t "${DIND_RUNNER_NAME}:${TAG}" \
|
||||
-f Dockerfile.dindrunner \
|
||||
. ${PUSH_ARG}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ if [ ! -z "${STARTUP_DELAY_IN_SECONDS}" ]; then
|
|||
sleep ${STARTUP_DELAY_IN_SECONDS}
|
||||
fi
|
||||
|
||||
if [[ "${DISABLE_WAIT_FOR_DOCKER}" != "true" ]] && [[ "${DOCKER_ENABLED}" == "true" ]]; then
|
||||
log "Docker enabled runner detected and Docker daemon wait is enabled"
|
||||
log "Waiting until Docker is avaliable or the timeout is reached"
|
||||
timeout 120s bash -c 'until docker ps ;do sleep 1; done'
|
||||
else
|
||||
log "Docker wait check skipped. Either Docker is disabled or the wait is disabled, continuing with entrypoint"
|
||||
fi
|
||||
|
||||
if [ -z "${GITHUB_URL}" ]; then
|
||||
log "Working with public GitHub"
|
||||
|
|
|
|||
Loading…
Reference in New Issue