Locally build runner image instead of pulling it (#473)
* Fix acceptance helm test not using newly built controller image * Locally build runner image instead of pulling it * Revert runner controller image pull policy to always and add a line to the test deployment to use IfNotPresent * Change runner repository from summerwind/action-runner to the owner of actions-runner-controller. Also fix some Makefile formatting. * Undo renaming acceptance/pull to docker-pull * Some env var cleanup Rename USERNAME to DOCKER_USER(is still used for github too tho) Add RUNNER_NAME var(defaults to $DOCKER_USER/actions-runner) Add TEST_REPO(defaults to $DOCKER_USER/actions-runner-controller)
This commit is contained in:
		
							parent
							
								
									358146ee54
								
							
						
					
					
						commit
						ba175148c8
					
				
							
								
								
									
										45
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										45
									
								
								Makefile
								
								
								
								
							|  | @ -1,5 +1,13 @@ | ||||||
| NAME ?= summerwind/actions-runner-controller | ifdef DOCKER_USER | ||||||
|  | 	NAME ?= ${DOCKER_USER}/actions-runner-controller | ||||||
|  | else | ||||||
|  | 	NAME ?= summerwind/actions-runner-controller | ||||||
|  | endif | ||||||
|  | DOCKER_USER ?= $(shell echo ${NAME} | cut -d / -f1) | ||||||
|  | RUNNER_NAME ?= ${DOCKER_USER}/actions-runner | ||||||
| VERSION ?= latest | VERSION ?= latest | ||||||
|  | TEST_REPO ?= ${DOCKER_USER}/actions-runner-controller | ||||||
|  | 
 | ||||||
| # From https://github.com/VictoriaMetrics/operator/pull/44
 | # From https://github.com/VictoriaMetrics/operator/pull/44
 | ||||||
| YAML_DROP=$(YQ) delete --inplace | YAML_DROP=$(YQ) delete --inplace | ||||||
| YAML_DROP_PREFIX=spec.validation.openAPIV3Schema.properties.spec.properties | YAML_DROP_PREFIX=spec.validation.openAPIV3Schema.properties.spec.properties | ||||||
|  | @ -24,8 +32,8 @@ endif | ||||||
| # if IMG_RESULT is unspecified, by default the image will be pushed to registry
 | # if IMG_RESULT is unspecified, by default the image will be pushed to registry
 | ||||||
| ifeq (${IMG_RESULT}, load) | ifeq (${IMG_RESULT}, load) | ||||||
| 	export PUSH_ARG="--load" | 	export PUSH_ARG="--load" | ||||||
|     # if load is specified, image will be built only for the build machine architecture. | 	# if load is specified, image will be built only for the build machine architecture. | ||||||
|     export PLATFORMS="local" | 	export PLATFORMS="local" | ||||||
| else ifeq (${IMG_RESULT}, cache) | else ifeq (${IMG_RESULT}, cache) | ||||||
| 	# if cache is specified, image will only be available in the build cache, it won't be pushed or loaded | 	# if cache is specified, image will only be available in the build cache, it won't be pushed or loaded | ||||||
| 	# therefore no PUSH_ARG will be specified | 	# therefore no PUSH_ARG will be specified | ||||||
|  | @ -107,10 +115,7 @@ generate: controller-gen | ||||||
| # Build the docker image
 | # Build the docker image
 | ||||||
| docker-build: test | docker-build: test | ||||||
| 	docker build . -t ${NAME}:${VERSION} | 	docker build . -t ${NAME}:${VERSION} | ||||||
| 
 | 	docker build runner -t ${RUNNER_NAME}:${VERSION} --build-arg TARGETPLATFORM=$(shell arch) | ||||||
| # Push the docker image
 |  | ||||||
| docker-push: |  | ||||||
| 	docker push ${NAME}:${VERSION} |  | ||||||
| 
 | 
 | ||||||
| docker-buildx: | docker-buildx: | ||||||
| 	export DOCKER_CLI_EXPERIMENTAL=enabled | 	export DOCKER_CLI_EXPERIMENTAL=enabled | ||||||
|  | @ -124,6 +129,11 @@ docker-buildx: | ||||||
| 		-f Dockerfile \
 | 		-f Dockerfile \
 | ||||||
| 		. ${PUSH_ARG} | 		. ${PUSH_ARG} | ||||||
| 
 | 
 | ||||||
|  | # Push the docker image
 | ||||||
|  | docker-push: | ||||||
|  | 	docker push ${NAME}:${VERSION} | ||||||
|  | 	docker push ${RUNNER_NAME}:${VERSION} | ||||||
|  | 
 | ||||||
| # Generate the release manifest file
 | # Generate the release manifest file
 | ||||||
| release: manifests | release: manifests | ||||||
| 	cd config/manager && kustomize edit set image controller=${NAME}:${VERSION} | 	cd config/manager && kustomize edit set image controller=${NAME}:${VERSION} | ||||||
|  | @ -135,8 +145,7 @@ release/clean: | ||||||
| 	rm -rf release | 	rm -rf release | ||||||
| 
 | 
 | ||||||
| .PHONY: acceptance | .PHONY: acceptance | ||||||
| acceptance: release/clean docker-build release | acceptance: release/clean acceptance/pull release | ||||||
| 	make acceptance/pull |  | ||||||
| 	ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | 	ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | ||||||
| 	ACCEPTANCE_TEST_SECRET_TYPE=app make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | 	ACCEPTANCE_TEST_SECRET_TYPE=app make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | ||||||
| 	ACCEPTANCE_TEST_DEPLOYMENT_TOOL=helm ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | 	ACCEPTANCE_TEST_DEPLOYMENT_TOOL=helm ACCEPTANCE_TEST_SECRET_TYPE=token make acceptance/kind acceptance/setup acceptance/tests acceptance/teardown | ||||||
|  | @ -146,20 +155,20 @@ acceptance/kind: | ||||||
| 	kind create cluster --name acceptance | 	kind create cluster --name acceptance | ||||||
| 	kind load docker-image ${NAME}:${VERSION} --name acceptance | 	kind load docker-image ${NAME}:${VERSION} --name acceptance | ||||||
| 	kind load docker-image quay.io/brancz/kube-rbac-proxy:v0.8.0 --name acceptance | 	kind load docker-image quay.io/brancz/kube-rbac-proxy:v0.8.0 --name acceptance | ||||||
| 	kind load docker-image summerwind/actions-runner:latest --name acceptance | 	kind load docker-image ${RUNNER_NAME}:${VERSION} --name acceptance | ||||||
| 	kind load docker-image docker:dind --name acceptance | 	kind load docker-image docker:dind --name acceptance | ||||||
| 	kind load docker-image quay.io/jetstack/cert-manager-controller:v1.0.4 --name acceptance | 	kind load docker-image quay.io/jetstack/cert-manager-controller:v1.0.4 --name acceptance | ||||||
| 	kind load docker-image quay.io/jetstack/cert-manager-cainjector:v1.0.4 --name acceptance | 	kind load docker-image quay.io/jetstack/cert-manager-cainjector:v1.0.4 --name acceptance | ||||||
| 	kind load docker-image quay.io/jetstack/cert-manager-webhook:v1.0.4 --name acceptance | 	kind load docker-image quay.io/jetstack/cert-manager-webhook:v1.0.4 --name acceptance | ||||||
| 	kubectl cluster-info --context kind-acceptance | 	kubectl cluster-info --context kind-acceptance | ||||||
| 
 | 
 | ||||||
| acceptance/pull: | # Pull the docker images for acceptance
 | ||||||
| 	docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0 | acceptance/pull: docker-build | ||||||
| 	docker pull summerwind/actions-runner:latest |         docker pull quay.io/brancz/kube-rbac-proxy:v0.8.0 | ||||||
| 	docker pull docker:dind |         docker pull docker:dind | ||||||
| 	docker pull quay.io/jetstack/cert-manager-controller:v1.0.4 |         docker pull quay.io/jetstack/cert-manager-controller:v1.0.4 | ||||||
| 	docker pull quay.io/jetstack/cert-manager-cainjector:v1.0.4 |         docker pull quay.io/jetstack/cert-manager-cainjector:v1.0.4 | ||||||
| 	docker pull quay.io/jetstack/cert-manager-webhook:v1.0.4 |         docker pull quay.io/jetstack/cert-manager-webhook:v1.0.4 | ||||||
| 
 | 
 | ||||||
| acceptance/setup: | acceptance/setup: | ||||||
| 	kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.yaml	#kubectl create namespace actions-runner-system | 	kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.yaml	#kubectl create namespace actions-runner-system | ||||||
|  | @ -174,7 +183,7 @@ acceptance/teardown: | ||||||
| 	kind delete cluster --name acceptance | 	kind delete cluster --name acceptance | ||||||
| 
 | 
 | ||||||
| acceptance/tests: | acceptance/tests: | ||||||
| 	acceptance/deploy.sh | 	NAME=${NAME} RUNNER_NAME=${RUNNER_NAME} DOCKER_USER=${DOCKER_USER} VERSION=${VERSION} TEST_REPO=${TEST_REPO} acceptance/deploy.sh | ||||||
| 	acceptance/checks.sh | 	acceptance/checks.sh | ||||||
| 
 | 
 | ||||||
| # Upload release file to GitHub.
 | # Upload release file to GitHub.
 | ||||||
|  |  | ||||||
|  | @ -786,12 +786,12 @@ the acceptance test: | ||||||
| # This sets `VERSION` envvar to some appropriate value | # This sets `VERSION` envvar to some appropriate value | ||||||
| . hack/make-env.sh | . hack/make-env.sh | ||||||
| 
 | 
 | ||||||
| NAME=$DOCKER_USER/actions-runner-controller \ | DOCKER_USER=*** \ | ||||||
|   GITHUB_TOKEN=*** \ |   GITHUB_TOKEN=*** \ | ||||||
|   APP_ID=*** \ |   APP_ID=*** \ | ||||||
|   PRIVATE_KEY_FILE_PATH=path/to/pem/file \ |   PRIVATE_KEY_FILE_PATH=path/to/pem/file \ | ||||||
|   INSTALLATION_ID=*** \ |   INSTALLATION_ID=*** \ | ||||||
|   make docker-build acceptance |   make acceptance | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain | Please follow the instructions explained in [Using Personal Access Token](#using-personal-access-token) to obtain | ||||||
|  | @ -806,7 +806,7 @@ If you prefer to test in a non-kind cluster, you can instead run: | ||||||
| 
 | 
 | ||||||
| ```shell script | ```shell script | ||||||
| KUBECONFIG=path/to/kubeconfig \ | KUBECONFIG=path/to/kubeconfig \ | ||||||
| NAME=$DOCKER_USER/actions-runner-controller \ |   DOCKER_USER=*** \ | ||||||
|   GITHUB_TOKEN=*** \ |   GITHUB_TOKEN=*** \ | ||||||
|   APP_ID=*** \ |   APP_ID=*** \ | ||||||
|   PRIVATE_KEY_FILE_PATH=path/to/pem/file \ |   PRIVATE_KEY_FILE_PATH=path/to/pem/file \ | ||||||
|  |  | ||||||
|  | @ -27,7 +27,9 @@ if [ "${tool}" == "helm" ]; then | ||||||
|     -n actions-runner-system \ |     -n actions-runner-system \ | ||||||
|     --create-namespace \ |     --create-namespace \ | ||||||
|     --set syncPeriod=5m \ |     --set syncPeriod=5m \ | ||||||
|     --set authSecret.create=false |     --set authSecret.create=false \ | ||||||
|  |     --set image.repository=${NAME} \ | ||||||
|  |     --set image.tag=${VERSION} | ||||||
|   kubectl -n actions-runner-system wait deploy/actions-runner-controller --for condition=available --timeout 60s |   kubectl -n actions-runner-system wait deploy/actions-runner-controller --for condition=available --timeout 60s | ||||||
| else | else | ||||||
|   kubectl apply \ |   kubectl apply \ | ||||||
|  | @ -39,5 +41,4 @@ fi | ||||||
| # Adhocly wait for some time until actions-runner-controller's admission webhook gets ready | # Adhocly wait for some time until actions-runner-controller's admission webhook gets ready | ||||||
| sleep 20 | sleep 20 | ||||||
| 
 | 
 | ||||||
| kubectl apply \ | cat acceptance/testdata/runnerdeploy.yaml | envsubst | kubectl apply -f - | ||||||
|   -f acceptance/testdata/runnerdeploy.yaml |  | ||||||
|  |  | ||||||
|  | @ -6,7 +6,10 @@ spec: | ||||||
| #  replicas: 1 | #  replicas: 1 | ||||||
|   template: |   template: | ||||||
|     spec: |     spec: | ||||||
|       repository: mumoshu/actions-runner-controller-ci |       repository: ${TEST_REPO} | ||||||
|  |       image: ${RUNNER_NAME}:${VERSION} | ||||||
|  |       imagePullPolicy: IfNotPresent | ||||||
|  | 
 | ||||||
|       # |       # | ||||||
|       # dockerd within runner container |       # dockerd within runner container | ||||||
|       # |       # | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp | ||||||
| # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | ||||||
| # to avoid rerunning apt-update on its own. | # to avoid rerunning apt-update on its own. | ||||||
| RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | ||||||
|     && if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ |     && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \ | ||||||
|     && mkdir -p "$RUNNER_ASSETS_DIR" \ |     && mkdir -p "$RUNNER_ASSETS_DIR" \ | ||||||
|     && cd "$RUNNER_ASSETS_DIR" \ |     && cd "$RUNNER_ASSETS_DIR" \ | ||||||
|     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ |     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ | ||||||
|  |  | ||||||
|  | @ -78,7 +78,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp | ||||||
| # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | ||||||
| # to avoid rerunning apt-update on its own. | # to avoid rerunning apt-update on its own. | ||||||
| RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | ||||||
|     && if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ |     && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \ | ||||||
|     && mkdir -p "$RUNNER_ASSETS_DIR" \ |     && mkdir -p "$RUNNER_ASSETS_DIR" \ | ||||||
|     && cd "$RUNNER_ASSETS_DIR" \ |     && cd "$RUNNER_ASSETS_DIR" \ | ||||||
|     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ |     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ | ||||||
|  |  | ||||||
|  | @ -67,7 +67,7 @@ ENV RUNNER_ASSETS_DIR=/runnertmp | ||||||
| # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | # It is installed after installdependencies.sh and before removing /var/lib/apt/lists | ||||||
| # to avoid rerunning apt-update on its own. | # to avoid rerunning apt-update on its own. | ||||||
| RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | RUN export ARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) \ | ||||||
|     && if [ "$ARCH" = "amd64" ]; then export ARCH=x64 ; fi \ |     && if [ "$ARCH" = "amd64" -o "$ARCH" = "x86_64" ]; then export ARCH=x64 ; fi \ | ||||||
|     && mkdir -p "$RUNNER_ASSETS_DIR" \ |     && mkdir -p "$RUNNER_ASSETS_DIR" \ | ||||||
|     && cd "$RUNNER_ASSETS_DIR" \ |     && cd "$RUNNER_ASSETS_DIR" \ | ||||||
|     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ |     && curl -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${ARCH}-${RUNNER_VERSION}.tar.gz \ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue