Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nginx base image in one place #8400

Merged
merged 26 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .codecov.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- 'charts/ingress-nginx/Chart.yaml'
- 'charts/ingress-nginx/**/*'


strongjz marked this conversation as resolved.
Show resolved Hide resolved
security:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -195,6 +196,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-chart-tests


kubernetes:
name: Kubernetes
runs-on: ubuntu-latest
Expand Down Expand Up @@ -251,6 +253,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-test


kubernetes-chroot:
name: Kubernetes chroot
runs-on: ubuntu-latest
Expand Down Expand Up @@ -308,6 +311,7 @@ jobs:
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-test


test-image-build:
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
Expand Down Expand Up @@ -374,6 +378,7 @@ jobs:
run: |
cd images/ext-auth-example-authsvc && make build


test-image:
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
Expand Down
85 changes: 54 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ ifneq ($(PLATFORM),)
PLATFORM_FLAG="--platform"
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

BASE_IMAGE ?= registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a
BASE_IMAGE ?= $(shell cat NGINX_BASE)

GOARCH=$(ARCH)

Expand All @@ -65,12 +72,14 @@ help: ## Display this help
.PHONY: image
image: clean-image ## Build image for a particular arch.
echo "Building docker image ($(ARCH))..."
@docker build \
docker build \
${PLATFORM_FLAG} ${PLATFORM} \
--no-cache \
$(MAC_DOCKER_FLAGS) \
--pull \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg TARGETARCH="$(ARCH)" \
--build-arg TARGET_ARCH="$(ARCH)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller:$(TAG) rootfs
Expand All @@ -82,14 +91,16 @@ gosec:
.PHONY: image-chroot
image-chroot: clean-chroot-image ## Build image for a particular arch.
echo "Building docker image ($(ARCH))..."
@docker build \
docker build \
--no-cache \
$(MAC_DOCKER_FLAGS) \
--pull \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg TARGETARCH="$(ARCH)" \
--build-arg TARGET_ARCH="$(ARCH)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--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
clean-image: ## Removes local image
Expand All @@ -105,64 +116,82 @@ clean-chroot-image: ## Removes local image

.PHONY: build
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) \
ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
build/build.sh


.PHONY: build-plugin
build-plugin: ## Build ingress-nginx krew plugin.
@build/run-in-docker.sh \
PKG=$(PKG) \
MAC_OS=$(MAC_OS) \
ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
build/build-plugin.sh


.PHONY: clean
clean: ## Remove .gocache directory.
rm -rf bin/ .gocache/ .cache/


.PHONY: static-check
static-check: ## Run verification script for boilerplate, codegen, gofmt, golint, lualint and chart-lint.
@build/run-in-docker.sh \
hack/verify-all.sh

###############################
# Tests for ingress-nginx
###############################

.PHONY: test
test: ## Run go unit tests.
@build/run-in-docker.sh \
PKG=$(PKG) \
MAC_OS=$(MAC_OS) \
ARCH=$(ARCH) \
COMMIT_SHA=$(COMMIT_SHA) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
build/test.sh
test/test.sh

.PHONY: lua-test
lua-test: ## Run lua unit tests.
@build/run-in-docker.sh \
BUSTED_ARGS=$(BUSTED_ARGS) \
build/test-lua.sh
MAC_OS=$(MAC_OS) \
test/test-lua.sh

.PHONY: e2e-test
e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster).
@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
e2e-test-binary: ## Build binary for e2e tests.
@build/run-in-docker.sh \
MAC_OS=$(MAC_OS) \
ginkgo build ./test/e2e

.PHONY: print-e2e-suite
print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests.
@build/run-in-docker.sh \
MAC_OS=$(MAC_OS) \
hack/print-e2e-suite.sh

.PHONY: vet
Expand All @@ -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.
@kind delete cluster --name ingress-nginx-dev



.PHONY: live-docs
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
Expand All @@ -202,14 +233,6 @@ misspell: ## Check for spelling errors.
-error \
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
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
@build/run-ingress-controller.sh
Expand All @@ -223,35 +246,35 @@ show-version:
echo -n $(TAG)

PLATFORMS ?= amd64 arm arm64 s390x

EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
BUILDX_PLATFORMS ?= linux/amd64,linux/arm,linux/arm64,linux/s390x

.PHONY: release # Build a multi-arch docker image
release: ensure-buildx clean
echo "Building binaries..."
$(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; ARCH=$(PLATFORM) make build;)

echo "Building and pushing ingress-nginx image..."
@docker buildx build \
echo "Building and pushing ingress-nginx image...$(BUILDX_PLATFORMS)"

docker buildx build \
--no-cache \
--push \
--pull \
--progress plain \
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \
--platform $(BUILDX_PLATFORMS) \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--build-arg BUILD_ID="$(BUILD_ID)" \
-t $(REGISTRY)/controller:$(TAG) rootfs
@docker buildx build \

docker buildx build \
--no-cache \
--push \
--pull \
--progress plain \
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \
--platform $(BUILDX_PLATFORMS) \
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
--build-arg VERSION="$(TAG)" \
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
--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 change: 1 addition & 0 deletions NGINX_BASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry.k8s.io/ingress-nginx/nginx:0ff500c23f34e939305de709cb6d47da34b66611@sha256:15f91034a03550dfab6ec50a7be4abbb683d087e234ad7fef5adedef54e46a5a
22 changes: 13 additions & 9 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GO_BUILD_CMD="go build"

if [ -n "$DEBUG" ]; then
set -x
GO_BUILD_CMD="go build -v"
fi

set -o errexit
Expand All @@ -31,39 +34,40 @@ mandatory=(
TAG
)

missing=false
for var in "${mandatory[@]}"; do
if [[ -z "${!var:-}" ]]; then
echo "Environment variable $var must be set"
missing=true
exit 1
fi
done

if [ "$missing" = true ]; then
exit 1
fi

export CGO_ENABLED=0
export GOARCH=${ARCH}

TARGETS_DIR="rootfs/bin/${ARCH}"
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 \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "${TARGETS_DIR}/nginx-ingress-controller" "${PKG}/cmd/nginx"

go build \
echo "Building ${PKG}/cmd/dbg"

${GO_BUILD_CMD} \
-trimpath -ldflags="-buildid= -w -s \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
-X ${PKG}/version.REPO=${REPO_INFO}" \
-o "${TARGETS_DIR}/dbg" "${PKG}/cmd/dbg"

go build \
echo "Building ${PKG}/cmd/waitshutdown"

${GO_BUILD_CMD} \
-trimpath -ldflags="-buildid= -w -s \
-X ${PKG}/version.RELEASE=${TAG} \
-X ${PKG}/version.COMMIT=${COMMIT_SHA} \
Expand Down
4 changes: 4 additions & 0 deletions build/run-e2e-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ trap cleanup EXIT
E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS:-}
FOCUS=${FOCUS:-.*}

BASEDIR=$(dirname "$0")
NGINX_BASE_IMAGE=$(cat $BASEDIR/../NGINX_BASE)

export E2E_CHECK_LEAKS
export FOCUS

Expand All @@ -76,6 +79,7 @@ kubectl run --rm \
--env="E2E_NODES=${E2E_NODES}" \
--env="FOCUS=${FOCUS}" \
--env="E2E_CHECK_LEAKS=${E2E_CHECK_LEAKS}" \
--env="NGINX_BASE_IMAGE=${NGINX_BASE_IMAGE}" \
--overrides='{ "apiVersion": "v1", "spec":{"serviceAccountName": "ingress-nginx-e2e"}}' \
e2e --image=nginx-ingress-controller:e2e

Loading