Update nginx base image in one place (#8400)

* update files to use one base image file

Signed-off-by: James Strong <strong.james.e@gmail.com>

* add chart test as well

Signed-off-by: James Strong <strong.james.e@gmail.com>

* update e2e-test image building

Signed-off-by: James Strong <strong.james.e@gmail.com>

* update e2e base image arg

Signed-off-by: James Strong <strong.james.e@gmail.com>

* add current e2e so test run

Signed-off-by: James Strong <strong.james.e@gmail.com>

* working on fixing build

* getting dev-env and make release to work

* test

* i think buildx is working on mac

* updates

* why docker for mac and linux cli differ

* fix target arch

* fix target arch

* fix loag issue

* fix issue

* update the chroot docker file

* fix docker base build

* mac is the issue

* env not getting to the e2e deployment.go file

* fix pull issue

* fix pull issue

* move test scripts into test folder

* clean up ci

* updates for PR

* remove unnesscary var
This commit is contained in:
James Strong 2022-07-08 12:27:47 -04:00 committed by GitHub
parent 8baac4214a
commit e1a16f6e74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 138 additions and 70 deletions

View file

@ -1,8 +0,0 @@
coverage:
status:
project:
default:
target: 40%
threshold: null
patch: false
changes: false

View file

@ -44,6 +44,7 @@ jobs:
- 'charts/ingress-nginx/Chart.yaml' - 'charts/ingress-nginx/Chart.yaml'
- 'charts/ingress-nginx/**/*' - 'charts/ingress-nginx/**/*'
security: security:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -195,6 +196,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-chart-tests make kind-e2e-chart-tests
kubernetes: kubernetes:
name: Kubernetes name: Kubernetes
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -251,6 +253,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-test make kind-e2e-test
kubernetes-chroot: kubernetes-chroot:
name: Kubernetes chroot name: Kubernetes chroot
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -308,6 +311,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-test make kind-e2e-test
test-image-build: test-image-build:
permissions: permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files contents: read # for dorny/paths-filter to fetch a list of changed files
@ -374,6 +378,7 @@ jobs:
run: | run: |
cd images/ext-auth-example-authsvc && make build cd images/ext-auth-example-authsvc && make build
test-image: test-image:
permissions: permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files contents: read # for dorny/paths-filter to fetch a list of changed files

View file

@ -53,9 +53,16 @@ ifneq ($(PLATFORM),)
PLATFORM_FLAG="--platform" PLATFORM_FLAG="--platform"
endif endif
MAC_OS = $(shell uname -s)
ifeq ($(MAC_OS), Darwin)
MAC_DOCKER_FLAGS="--load"
else
MAC_DOCKER_FLAGS=
endif
REGISTRY ?= gcr.io/k8s-staging-ingress-nginx REGISTRY ?= gcr.io/k8s-staging-ingress-nginx
BASE_IMAGE ?= registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a BASE_IMAGE ?= $(shell cat NGINX_BASE)
GOARCH=$(ARCH) GOARCH=$(ARCH)
@ -65,12 +72,14 @@ help: ## Display this help
.PHONY: image .PHONY: image
image: clean-image ## Build image for a particular arch. image: clean-image ## Build image for a particular arch.
echo "Building docker image ($(ARCH))..." echo "Building docker image ($(ARCH))..."
@docker build \ docker build \
${PLATFORM_FLAG} ${PLATFORM} \ ${PLATFORM_FLAG} ${PLATFORM} \
--no-cache \ --no-cache \
$(MAC_DOCKER_FLAGS) \
--pull \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \ --build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \ --build-arg VERSION="$(TAG)" \
--build-arg TARGETARCH="$(ARCH)" \ --build-arg TARGET_ARCH="$(ARCH)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \ --build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \ --build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller:$(TAG) rootfs -t $(REGISTRY)/controller:$(TAG) rootfs
@ -82,14 +91,16 @@ gosec:
.PHONY: image-chroot .PHONY: image-chroot
image-chroot: clean-chroot-image ## Build image for a particular arch. image-chroot: clean-chroot-image ## Build image for a particular arch.
echo "Building docker image ($(ARCH))..." echo "Building docker image ($(ARCH))..."
@docker build \ docker build \
--no-cache \ --no-cache \
$(MAC_DOCKER_FLAGS) \
--pull \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \ --build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \ --build-arg VERSION="$(TAG)" \
--build-arg TARGETARCH="$(ARCH)" \ --build-arg TARGET_ARCH="$(ARCH)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \ --build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \ --build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile.chroot -t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile-chroot
.PHONY: clean-image .PHONY: clean-image
clean-image: ## Removes local image clean-image: ## Removes local image
@ -105,64 +116,82 @@ clean-chroot-image: ## Removes local image
.PHONY: build .PHONY: build
build: ## Build ingress controller, debug tool and pre-stop hook. build: ## Build ingress controller, debug tool and pre-stop hook.
@build/run-in-docker.sh \ build/run-in-docker.sh \
MAC_OS=$(MAC_OS) \
PKG=$(PKG) \ PKG=$(PKG) \
ARCH=$(ARCH) \ ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \ COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \ REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \ TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
build/build.sh build/build.sh
.PHONY: build-plugin .PHONY: build-plugin
build-plugin: ## Build ingress-nginx krew plugin. build-plugin: ## Build ingress-nginx krew plugin.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
PKG=$(PKG) \ PKG=$(PKG) \
MAC_OS=$(MAC_OS) \
ARCH=$(ARCH) \ ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \ COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \ REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \ TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
build/build-plugin.sh build/build-plugin.sh
.PHONY: clean .PHONY: clean
clean: ## Remove .gocache directory. clean: ## Remove .gocache directory.
rm -rf bin/ .gocache/ .cache/ rm -rf bin/ .gocache/ .cache/
.PHONY: static-check .PHONY: static-check
static-check: ## Run verification script for boilerplate, codegen, gofmt, golint, lualint and chart-lint. static-check: ## Run verification script for boilerplate, codegen, gofmt, golint, lualint and chart-lint.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
hack/verify-all.sh hack/verify-all.sh
###############################
# Tests for ingress-nginx
###############################
.PHONY: test .PHONY: test
test: ## Run go unit tests. test: ## Run go unit tests.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
PKG=$(PKG) \ PKG=$(PKG) \
MAC_OS=$(MAC_OS) \
ARCH=$(ARCH) \ ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \ COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \ REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \ TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \ test/test.sh
build/test.sh
.PHONY: lua-test .PHONY: lua-test
lua-test: ## Run lua unit tests. lua-test: ## Run lua unit tests.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
BUSTED_ARGS=$(BUSTED_ARGS) \ BUSTED_ARGS=$(BUSTED_ARGS) \
build/test-lua.sh MAC_OS=$(MAC_OS) \
test/test-lua.sh
.PHONY: e2e-test .PHONY: e2e-test
e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster). e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster).
@build/run-e2e-suite.sh @build/run-e2e-suite.sh
.PHONY: kind-e2e-test
kind-e2e-test: ## Run e2e tests using kind.
@test/e2e/run.sh
.PHONY: kind-e2e-chart-tests
kind-e2e-chart-tests: ## Run helm chart e2e tests
@test/e2e/run-chart-test.sh
.PHONY: e2e-test-binary .PHONY: e2e-test-binary
e2e-test-binary: ## Build binary for e2e tests. e2e-test-binary: ## Build binary for e2e tests.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
MAC_OS=$(MAC_OS) \
ginkgo build ./test/e2e ginkgo build ./test/e2e
.PHONY: print-e2e-suite .PHONY: print-e2e-suite
print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests. print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests.
@build/run-in-docker.sh \ @build/run-in-docker.sh \
MAC_OS=$(MAC_OS) \
hack/print-e2e-suite.sh hack/print-e2e-suite.sh
.PHONY: vet .PHONY: vet
@ -185,6 +214,8 @@ dev-env: ## Starts a local Kubernetes cluster using kind, building and deployin
dev-env-stop: ## Deletes local Kubernetes cluster created by kind. dev-env-stop: ## Deletes local Kubernetes cluster created by kind.
@kind delete cluster --name ingress-nginx-dev @kind delete cluster --name ingress-nginx-dev
.PHONY: live-docs .PHONY: live-docs
live-docs: ## Build and launch a local copy of the documentation website in http://localhost:8000 live-docs: ## Build and launch a local copy of the documentation website in http://localhost:8000
@docker build ${PLATFORM_FLAG} ${PLATFORM} -t ingress-nginx-docs .github/actions/mkdocs @docker build ${PLATFORM_FLAG} ${PLATFORM} -t ingress-nginx-docs .github/actions/mkdocs
@ -202,14 +233,6 @@ misspell: ## Check for spelling errors.
-error \ -error \
cmd/* internal/* deploy/* docs/* design/* test/* README.md cmd/* internal/* deploy/* docs/* design/* test/* README.md
.PHONY: kind-e2e-test
kind-e2e-test: ## Run e2e tests using kind.
@test/e2e/run.sh
.PHONY: kind-e2e-chart-tests
kind-e2e-chart-tests: ## Run helm chart e2e tests
@test/e2e/run-chart-test.sh
.PHONY: run-ingress-controller .PHONY: run-ingress-controller
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection. run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
@build/run-ingress-controller.sh @build/run-ingress-controller.sh
@ -223,35 +246,35 @@ show-version:
echo -n $(TAG) echo -n $(TAG)
PLATFORMS ?= amd64 arm arm64 s390x PLATFORMS ?= amd64 arm arm64 s390x
BUILDX_PLATFORMS ?= linux/amd64,linux/arm,linux/arm64,linux/s390x
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
.PHONY: release # Build a multi-arch docker image .PHONY: release # Build a multi-arch docker image
release: ensure-buildx clean release: ensure-buildx clean
echo "Building binaries..." echo "Building binaries..."
$(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; ARCH=$(PLATFORM) make build;) $(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; ARCH=$(PLATFORM) make build;)
echo "Building and pushing ingress-nginx image..." echo "Building and pushing ingress-nginx image...$(BUILDX_PLATFORMS)"
@docker buildx build \
docker buildx build \
--no-cache \ --no-cache \
--push \ --push \
--pull \
--progress plain \ --progress plain \
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \ --platform $(BUILDX_PLATFORMS) \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \ --build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \ --build-arg VERSION="$(TAG)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \ --build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \ --build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller:$(TAG) rootfs -t $(REGISTRY)/controller:$(TAG) rootfs
@docker buildx build \ docker buildx build \
--no-cache \ --no-cache \
--push \ --push \
--pull \
--progress plain \ --progress plain \
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \ --platform $(BUILDX_PLATFORMS) \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \ --build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \ --build-arg VERSION="$(TAG)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \ --build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \ --build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile.chroot -t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile-chroot

1
NGINX_BASE Normal file
View file

@ -0,0 +1 @@
registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a

View file

@ -14,8 +14,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
GO_BUILD_CMD="go build"
if [ -n "$DEBUG" ]; then if [ -n "$DEBUG" ]; then
set -x set -x
GO_BUILD_CMD="go build -v"
fi fi
set -o errexit set -o errexit
@ -31,17 +34,12 @@ mandatory=(
TAG TAG
) )
missing=false
for var in "${mandatory[@]}"; do for var in "${mandatory[@]}"; do
if [[ -z "${!var:-}" ]]; then if [[ -z "${!var:-}" ]]; then
echo "Environment variable $var must be set" echo "Environment variable $var must be set"
missing=true
fi
done
if [ "$missing" = true ]; then
exit 1 exit 1
fi fi
done
export CGO_ENABLED=0 export CGO_ENABLED=0
export GOARCH=${ARCH} export GOARCH=${ARCH}
@ -49,21 +47,27 @@ export GOARCH=${ARCH}
TARGETS_DIR="rootfs/bin/${ARCH}" TARGETS_DIR="rootfs/bin/${ARCH}"
echo "Building targets for ${ARCH}, generated targets in ${TARGETS_DIR} directory." echo "Building targets for ${ARCH}, generated targets in ${TARGETS_DIR} directory."
go build \ echo "Building ${PKG}/cmd/nginx"
${GO_BUILD_CMD} \
-trimpath -ldflags="-buildid= -w -s \ -trimpath -ldflags="-buildid= -w -s \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \ -X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \ -X ${PKG}/version.REPO=${REPO_INFO}" \
-o "${TARGETS_DIR}/nginx-ingress-controller" "${PKG}/cmd/nginx" -o "${TARGETS_DIR}/nginx-ingress-controller" "${PKG}/cmd/nginx"
go build \ echo "Building ${PKG}/cmd/dbg"
${GO_BUILD_CMD} \
-trimpath -ldflags="-buildid= -w -s \ -trimpath -ldflags="-buildid= -w -s \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \ -X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \ -X ${PKG}/version.REPO=${REPO_INFO}" \
-o "${TARGETS_DIR}/dbg" "${PKG}/cmd/dbg" -o "${TARGETS_DIR}/dbg" "${PKG}/cmd/dbg"
go build \ echo "Building ${PKG}/cmd/waitshutdown"
${GO_BUILD_CMD} \
-trimpath -ldflags="-buildid= -w -s \ -trimpath -ldflags="-buildid= -w -s \
-X ${PKG}/version.RELEASE=${TAG} \ -X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \ -X ${PKG}/version.COMMIT=${COMMIT_SHA} \

View file

@ -51,6 +51,9 @@ trap cleanup EXIT
E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS:-} E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS:-}
FOCUS=${FOCUS:-.*} FOCUS=${FOCUS:-.*}
BASEDIR=$(dirname "$0")
NGINX_BASE_IMAGE=$(cat $BASEDIR/../NGINX_BASE)
export E2E_CHECK_LEAKS export E2E_CHECK_LEAKS
export FOCUS export FOCUS
@ -76,6 +79,7 @@ kubectl run --rm \
--env="E2E_NODES=${E2E_NODES}" \ --env="E2E_NODES=${E2E_NODES}" \
--env="FOCUS=${FOCUS}" \ --env="FOCUS=${FOCUS}" \
--env="E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS}" \ --env="E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS}" \
--env="NGINX_BASE_IMAGE=${NGINX_BASE_IMAGE}" \
--overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e"}}' \ --overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e"}}' \
e2e --image=nginx-ingress-controller:e2e e2e --image=nginx-ingress-controller:e2e

View file

@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if [ -n "$DEBUG" ]; then DEBUG=${DEBUG:-"false"}
if [ "$DEBUG" == "true" ]; then
set -x set -x
fi fi
@ -62,6 +63,14 @@ else
PLATFORM_FLAG= PLATFORM_FLAG=
fi fi
USER=${USER:-nobody}
if [[ ${MAC_OS} == "Darwin" ]]; then
MAC_DOCKER_FLAGS=""
else
MAC_DOCKER_FLAGS="-u $(id -u ${USER}):$(id -g ${USER})" #idk why mac/git fails on the gobuild if these are presented to dockerrun.sh script
fi
echo "..printing env & other vars to stdout" echo "..printing env & other vars to stdout"
echo "HOSTNAME=`hostname`" echo "HOSTNAME=`hostname`"
uname -a uname -a
@ -80,12 +89,13 @@ if [[ "$DOCKER_IN_DOCKER_ENABLED" == "true" ]]; then
/bin/bash -c "${FLAGS}" /bin/bash -c "${FLAGS}"
set +x set +x
else else
echo "..reached DIND check ELSE block, inside run-in-docker.sh" echo "Reached DIND check ELSE block, inside run-in-docker.sh"
docker run \ docker run \
${PLATFORM_FLAG} ${PLATFORM} \ ${PLATFORM_FLAG} ${PLATFORM} \
--tty \ --tty \
--rm \ --rm \
${DOCKER_OPTS} \ ${DOCKER_OPTS} \
-e DEBUG=${DEBUG} \
-e GOCACHE="/go/src/${PKG}/.cache" \ -e GOCACHE="/go/src/${PKG}/.cache" \
-e GOMODCACHE="/go/src/${PKG}/.modcache" \ -e GOMODCACHE="/go/src/${PKG}/.modcache" \
-e DOCKER_IN_DOCKER_ENABLED="true" \ -e DOCKER_IN_DOCKER_ENABLED="true" \
@ -95,6 +105,6 @@ else
-v "/var/run/docker.sock:/var/run/docker.sock" \ -v "/var/run/docker.sock:/var/run/docker.sock" \
-v "${INGRESS_VOLUME}:/etc/ingress-controller/" \ -v "${INGRESS_VOLUME}:/etc/ingress-controller/" \
-w "/go/src/${PKG}" \ -w "/go/src/${PKG}" \
-u $(id -u ${USER}):$(id -g ${USER}) \ ${MAC_DOCKER_FLAGS} \
${E2E_IMAGE} /bin/bash -c "${FLAGS}" ${E2E_IMAGE} /bin/bash -c "${FLAGS}"
fi fi

View file

@ -26,6 +26,7 @@ IMAGE = $(REGISTRY)/e2e-test-echo
# required to enable buildx # required to enable buildx
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled
BASE_IMAGE = $(shell cat $(DIR)/../../NGINX_BASE)
# build with buildx # build with buildx
PLATFORMS?=linux/amd64 PLATFORMS?=linux/amd64
OUTPUT= OUTPUT=
@ -36,7 +37,7 @@ build: ensure-buildx
--platform=${PLATFORMS} $(OUTPUT) \ --platform=${PLATFORMS} $(OUTPUT) \
--progress=$(PROGRESS) \ --progress=$(PROGRESS) \
--pull \ --pull \
--build-arg BASE_IMAGE=registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a \ --build-arg BASE_IMAGE=${BASE_IMAGE} \
--build-arg LUAROCKS_VERSION=3.8.0 \ --build-arg LUAROCKS_VERSION=3.8.0 \
--build-arg LUAROCKS_SHA=ab6612ca9ab87c6984871d2712d05525775e8b50172701a0a1cabddf76de2be7 \ --build-arg LUAROCKS_SHA=ab6612ca9ab87c6984871d2712d05525775e8b50172701a0a1cabddf76de2be7 \
-t $(IMAGE):$(TAG) rootfs -t $(IMAGE):$(TAG) rootfs

View file

@ -19,7 +19,9 @@ This image provides a default configuration file with no backend servers.
_Using docker_ _Using docker_
NGINX base image we use is defined in NGINX_BASE file at the root of the project
```console ```console
docker run -v /some/nginx.conf:/etc/nginx/nginx.conf:ro registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a docker run -v /some/nginx.conf:/etc/nginx/nginx.conf:ro $(cat ../../NGINX_BASE)
``` ```

View file

@ -23,7 +23,7 @@ REGISTRY ?= local
IMAGE = $(REGISTRY)/e2e-test-runner IMAGE = $(REGISTRY)/e2e-test-runner
NGINX_BASE_IMAGE ?= registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a NGINX_BASE_IMAGE ?= $(shell cat $DIR/../../NGINX_BASE)
# required to enable buildx # required to enable buildx
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled

View file

@ -16,7 +16,7 @@ ARG BASE_IMAGE
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
ARG TARGETARCH ARG TARGET_ARCH
ARG VERSION ARG VERSION
ARG COMMIT_SHA ARG COMMIT_SHA
ARG BUILD_ID=UNSET ARG BUILD_ID=UNSET
@ -41,9 +41,9 @@ RUN apk update \
COPY --chown=www-data:www-data etc /etc COPY --chown=www-data:www-data etc /etc
COPY --chown=www-data:www-data bin/${TARGETARCH}/dbg / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/dbg /
COPY --chown=www-data:www-data bin/${TARGETARCH}/nginx-ingress-controller / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/nginx-ingress-controller /
COPY --chown=www-data:www-data bin/${TARGETARCH}/wait-shutdown / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/wait-shutdown /
# Fix permission during the build to avoid issues at runtime # Fix permission during the build to avoid issues at runtime
# with volumes (custom templates) # with volumes (custom templates)

View file

@ -25,7 +25,7 @@ RUN apk update \
FROM alpine:3.16.0 FROM alpine:3.16.0
ARG TARGETARCH ARG TARGET_ARCH
ARG VERSION ARG VERSION
ARG COMMIT_SHA ARG COMMIT_SHA
ARG BUILD_ID=UNSET ARG BUILD_ID=UNSET
@ -64,9 +64,9 @@ COPY --from=chroot /chroot /chroot
COPY --chown=www-data:www-data etc /chroot/etc COPY --chown=www-data:www-data etc /chroot/etc
COPY --chown=www-data:www-data bin/${TARGETARCH}/dbg / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/dbg /
COPY --chown=www-data:www-data bin/${TARGETARCH}/nginx-ingress-controller / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/nginx-ingress-controller /
COPY --chown=www-data:www-data bin/${TARGETARCH}/wait-shutdown / COPY --chown=www-data:www-data bin/${TARGET_ARCH}/wait-shutdown /
COPY --chown=www-data:www-data nginx-chroot-wrapper.sh /usr/bin/nginx COPY --chown=www-data:www-data nginx-chroot-wrapper.sh /usr/bin/nginx
WORKDIR /chroot/etc/nginx WORKDIR /chroot/etc/nginx

View file

@ -1,4 +1,5 @@
FROM registry.k8s.io/ingress-nginx/e2e-test-runner:v20220624-g3348cd71e@sha256:2a34e322b7ff89abdfa0b6202f903bf5618578b699ff609a3ddabac0aae239c8 AS BASE ARG E2E_BASE_IMAGE
FROM ${E2E_BASE_IMAGE} AS BASE
FROM alpine:3.16.0 FROM alpine:3.16.0

View file

@ -1,5 +1,6 @@
DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
E2E_BASE_IMAGE="k8s.gcr.io/ingress-nginx/e2e-test-runner:v20220110-gfd820db46@sha256:273f7d9b1b2297cd96b4d51600e45d932186a1cc79d00d179dfb43654112fe8f"
image: image:
echo "..entered Makefile in /test/e2e-image" echo "..entered Makefile in /test/e2e-image"
@ -15,6 +16,7 @@ image:
cp -R $(DIR)/../../test/e2e/settings/ocsp/* . cp -R $(DIR)/../../test/e2e/settings/ocsp/* .
docker build \ docker build \
--build-arg E2E_BASE_IMAGE=$(E2E_BASE_IMAGE) \
--tag nginx-ingress-controller:e2e . --tag nginx-ingress-controller:e2e .
clean: clean:

View file

@ -18,6 +18,8 @@ package framework
import ( import (
"context" "context"
"errors"
"os"
"time" "time"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
@ -37,13 +39,11 @@ const SlowEchoService = "slow-echo"
// HTTPBinService name of the deployment for the httpbin app // HTTPBinService name of the deployment for the httpbin app
const HTTPBinService = "httpbin" const HTTPBinService = "httpbin"
// NginxBaseImage use for testing
const NginxBaseImage = "registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a"
type deploymentOptions struct { type deploymentOptions struct {
namespace string namespace string
name string name string
replicas int replicas int
image string
} }
// WithDeploymentNamespace allows configuring the deployment's namespace // WithDeploymentNamespace allows configuring the deployment's namespace
@ -150,6 +150,16 @@ http {
f.NGINXWithConfigDeployment(SlowEchoService, cfg) f.NGINXWithConfigDeployment(SlowEchoService, cfg)
} }
func (f *Framework) GetNginxBaseImage() string {
nginxBaseImage := os.Getenv("NGINX_BASE_IMAGE")
if nginxBaseImage == "" {
assert.NotEmpty(ginkgo.GinkgoT(), errors.New("NGINX_BASE_IMAGE not defined"), "NGINX_BASE_IMAGE not defined")
}
return nginxBaseImage
}
// NGINXDeployment creates a new simple NGINX Deployment using NGINX base image // NGINXDeployment creates a new simple NGINX Deployment using NGINX base image
// and passing the desired configuration // and passing the desired configuration
func (f *Framework) NGINXDeployment(name string, cfg string, waitendpoint bool) { func (f *Framework) NGINXDeployment(name string, cfg string, waitendpoint bool) {
@ -166,7 +176,7 @@ func (f *Framework) NGINXDeployment(name string, cfg string, waitendpoint bool)
}, metav1.CreateOptions{}) }, metav1.CreateOptions{})
assert.Nil(ginkgo.GinkgoT(), err, "creating configmap") assert.Nil(ginkgo.GinkgoT(), err, "creating configmap")
deployment := newDeployment(name, f.Namespace, NginxBaseImage, 80, 1, deployment := newDeployment(name, f.Namespace, f.GetNginxBaseImage(), 80, 1,
nil, nil,
[]corev1.VolumeMount{ []corev1.VolumeMount{
{ {

View file

@ -50,6 +50,13 @@ export TAG=1.0.0-dev
export ARCH=${ARCH:-amd64} export ARCH=${ARCH:-amd64}
export REGISTRY=ingress-controller export REGISTRY=ingress-controller
BASEDIR=$(dirname "$0")
NGINX_BASE_IMAGE=$(cat $BASEDIR/../../NGINX_BASE)
echo "Running e2e with nginx base image ${NGINX_BASE_IMAGE}"
export NGINX_BASE_IMAGE=$NGINX_BASE_IMAGE
export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}" export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}"
if [ "${SKIP_CLUSTER_CREATION:-false}" = "false" ]; then if [ "${SKIP_CLUSTER_CREATION:-false}" = "false" ]; then

View file

@ -51,6 +51,12 @@ export TAG=1.0.0-dev
export ARCH=${ARCH:-amd64} export ARCH=${ARCH:-amd64}
export REGISTRY=ingress-controller export REGISTRY=ingress-controller
NGINX_BASE_IMAGE=$(cat $DIR/../../NGINX_BASE)
echo "Running e2e with nginx base image ${NGINX_BASE_IMAGE}"
export NGINX_BASE_IMAGE=$NGINX_BASE_IMAGE
export DOCKER_CLI_EXPERIMENTAL=enabled export DOCKER_CLI_EXPERIMENTAL=enabled
export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}" export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/kind-config-$KIND_CLUSTER_NAME}"