2017-10-17 19:50:27 -03:00
|
|
|
# Copyright 2017 The Kubernetes Authors.
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
2020-01-07 10:53:12 -03:00
|
|
|
# Add the following 'help' target to your Makefile
|
|
|
|
|
# And add help text after each target name starting with '\#\#'
|
|
|
|
|
|
|
|
|
|
.DEFAULT_GOAL:=help
|
2016-11-10 22:45:20 -03:00
|
|
|
|
2020-01-09 00:58:16 -03:00
|
|
|
.EXPORT_ALL_VARIABLES:
|
|
|
|
|
|
|
|
|
|
ifndef VERBOSE
|
|
|
|
|
.SILENT:
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# set default shell
|
2020-02-16 15:27:39 -03:00
|
|
|
SHELL=/bin/bash -o pipefail -o errexit
|
2020-01-09 00:58:16 -03:00
|
|
|
|
2017-10-06 16:58:36 -03:00
|
|
|
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
|
2020-07-05 20:22:59 +09:00
|
|
|
TAG ?= $(shell cat TAG)
|
2018-05-26 12:48:59 -04:00
|
|
|
|
|
|
|
|
# e2e settings
|
|
|
|
|
# Allow limiting the scope of the e2e tests. By default run everything
|
2018-07-05 23:23:27 -04:00
|
|
|
FOCUS ?= .*
|
2018-05-26 12:48:59 -04:00
|
|
|
# number of parallel test
|
2020-09-30 12:58:39 -03:00
|
|
|
E2E_NODES ?= 7
|
2020-01-07 10:53:12 -03:00
|
|
|
# run e2e test suite with tests that check for memory leaks? (default is false)
|
2019-06-27 10:03:20 -04:00
|
|
|
E2E_CHECK_LEAKS ?=
|
|
|
|
|
|
2019-05-13 22:31:30 -04:00
|
|
|
REPO_INFO ?= $(shell git config --get remote.origin.url)
|
2020-08-19 21:20:40 -04:00
|
|
|
COMMIT_SHA ?= git-$(shell git rev-parse --short HEAD)
|
2020-08-27 09:18:09 -04:00
|
|
|
BUILD_ID ?= "UNSET"
|
2016-11-10 22:45:20 -03:00
|
|
|
|
2018-07-05 23:23:27 -04:00
|
|
|
PKG = k8s.io/ingress-nginx
|
2016-11-10 22:45:20 -03:00
|
|
|
|
2020-03-19 07:06:12 -04:00
|
|
|
HOST_ARCH = $(shell which go >/dev/null 2>&1 && go env GOARCH)
|
|
|
|
|
ARCH ?= $(HOST_ARCH)
|
|
|
|
|
ifeq ($(ARCH),)
|
|
|
|
|
$(error mandatory variable ARCH is empty, either set it when calling the command or make sure 'go env GOARCH' works)
|
|
|
|
|
endif
|
2019-05-24 10:33:16 -04:00
|
|
|
|
2022-04-06 16:46:26 -04:00
|
|
|
ifneq ($(PLATFORM),)
|
|
|
|
|
PLATFORM_FLAG="--platform"
|
|
|
|
|
endif
|
|
|
|
|
|
2020-07-08 17:56:50 -04:00
|
|
|
REGISTRY ?= gcr.io/k8s-staging-ingress-nginx
|
2019-06-26 08:12:00 -04:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
BASE_IMAGE ?= $(shell cat NGINX_BASE)
|
2020-01-07 10:53:12 -03:00
|
|
|
|
2020-01-31 22:56:55 -03:00
|
|
|
GOARCH=$(ARCH)
|
2020-01-09 00:58:16 -03:00
|
|
|
|
2020-01-07 10:53:12 -03:00
|
|
|
help: ## Display this help
|
2020-09-16 07:47:24 -03:00
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
2020-01-07 10:53:12 -03:00
|
|
|
|
2020-05-30 23:25:56 -04:00
|
|
|
.PHONY: image
|
2020-06-01 21:22:32 -04:00
|
|
|
image: clean-image ## Build image for a particular arch.
|
2020-01-26 10:07:55 -03:00
|
|
|
echo "Building docker image ($(ARCH))..."
|
2022-07-08 12:27:47 -04:00
|
|
|
docker build \
|
2022-04-06 16:46:26 -04:00
|
|
|
${PLATFORM_FLAG} ${PLATFORM} \
|
2020-01-26 10:07:55 -03:00
|
|
|
--no-cache \
|
2022-07-08 12:27:47 -04:00
|
|
|
--pull \
|
2020-05-29 18:31:13 -04:00
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
2020-01-31 22:56:55 -03:00
|
|
|
--build-arg VERSION="$(TAG)" \
|
2022-07-11 09:00:08 -03:00
|
|
|
--build-arg TARGETARCH="$(ARCH)" \
|
2020-08-19 21:20:40 -04:00
|
|
|
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
|
2020-08-27 09:18:09 -04:00
|
|
|
--build-arg BUILD_ID="$(BUILD_ID)" \
|
2020-07-08 17:56:50 -04:00
|
|
|
-t $(REGISTRY)/controller:$(TAG) rootfs
|
2017-10-06 16:58:36 -03:00
|
|
|
|
2022-06-15 13:19:30 -04:00
|
|
|
.PHONY: gosec
|
|
|
|
|
gosec:
|
2022-06-15 14:15:27 -04:00
|
|
|
docker run --rm -it -w /source/ -v "$(pwd)"/:/source securego/gosec:2.11.0 -exclude=G109,G601,G104,G204,G304,G306,G307 -tests=false -exclude-dir=test -exclude-dir=images/ -exclude-dir=docs/ /source/...
|
2022-06-15 13:19:30 -04:00
|
|
|
|
2022-04-09 01:48:04 -03:00
|
|
|
.PHONY: image-chroot
|
|
|
|
|
image-chroot: clean-chroot-image ## Build image for a particular arch.
|
|
|
|
|
echo "Building docker image ($(ARCH))..."
|
2022-07-08 12:27:47 -04:00
|
|
|
docker build \
|
2022-04-09 01:48:04 -03:00
|
|
|
--no-cache \
|
2022-07-08 12:27:47 -04:00
|
|
|
--pull \
|
2022-04-09 01:48:04 -03:00
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
|
|
|
|
--build-arg VERSION="$(TAG)" \
|
2022-07-11 09:00:08 -03:00
|
|
|
--build-arg TARGETARCH="$(ARCH)" \
|
2022-04-09 01:48:04 -03:00
|
|
|
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
|
|
|
|
|
--build-arg BUILD_ID="$(BUILD_ID)" \
|
2022-07-08 12:27:47 -04:00
|
|
|
-t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile-chroot
|
2022-04-09 01:48:04 -03:00
|
|
|
|
2020-05-30 23:25:56 -04:00
|
|
|
.PHONY: clean-image
|
|
|
|
|
clean-image: ## Removes local image
|
2020-07-08 17:56:50 -04:00
|
|
|
echo "removing old image $(REGISTRY)/controller:$(TAG)"
|
|
|
|
|
@docker rmi -f $(REGISTRY)/controller:$(TAG) || true
|
2020-04-28 19:42:11 -04:00
|
|
|
|
2022-04-09 01:48:04 -03:00
|
|
|
|
|
|
|
|
.PHONY: clean-chroot-image
|
|
|
|
|
clean-chroot-image: ## Removes local image
|
|
|
|
|
echo "removing old image $(REGISTRY)/controller-chroot:$(TAG)"
|
|
|
|
|
@docker rmi -f $(REGISTRY)/controller-chroot:$(TAG) || true
|
|
|
|
|
|
|
|
|
|
|
2017-11-12 01:51:41 -03:00
|
|
|
.PHONY: build
|
2020-06-27 11:57:00 -04:00
|
|
|
build: ## Build ingress controller, debug tool and pre-stop hook.
|
2022-07-08 12:27:47 -04:00
|
|
|
build/run-in-docker.sh \
|
|
|
|
|
MAC_OS=$(MAC_OS) \
|
2020-01-09 00:58:16 -03:00
|
|
|
PKG=$(PKG) \
|
2020-01-09 13:48:43 -03:00
|
|
|
ARCH=$(ARCH) \
|
2020-08-19 21:20:40 -04:00
|
|
|
COMMIT_SHA=$(COMMIT_SHA) \
|
2020-01-09 00:58:16 -03:00
|
|
|
REPO_INFO=$(REPO_INFO) \
|
|
|
|
|
TAG=$(TAG) \
|
|
|
|
|
build/build.sh
|
2018-07-05 23:23:27 -04:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
|
2018-08-02 23:58:58 +03:00
|
|
|
.PHONY: clean
|
2020-01-07 10:53:12 -03:00
|
|
|
clean: ## Remove .gocache directory.
|
2020-02-16 15:27:57 +01:00
|
|
|
rm -rf bin/ .gocache/ .cache/
|
2016-11-10 22:45:20 -03:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
|
2018-07-05 23:23:27 -04:00
|
|
|
.PHONY: static-check
|
2020-02-25 21:14:21 -03:00
|
|
|
static-check: ## Run verification script for boilerplate, codegen, gofmt, golint, lualint and chart-lint.
|
2020-01-09 00:58:16 -03:00
|
|
|
@build/run-in-docker.sh \
|
2022-07-10 02:41:46 +08:00
|
|
|
MAC_OS=$(MAC_OS) \
|
2020-02-25 21:14:21 -03:00
|
|
|
hack/verify-all.sh
|
2017-10-06 16:58:36 -03:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
###############################
|
|
|
|
|
# Tests for ingress-nginx
|
|
|
|
|
###############################
|
|
|
|
|
|
2017-11-12 01:51:41 -03:00
|
|
|
.PHONY: test
|
2020-06-27 11:57:00 -04:00
|
|
|
test: ## Run go unit tests.
|
2020-01-09 00:58:16 -03:00
|
|
|
@build/run-in-docker.sh \
|
|
|
|
|
PKG=$(PKG) \
|
2022-07-08 12:27:47 -04:00
|
|
|
MAC_OS=$(MAC_OS) \
|
2020-01-09 13:48:43 -03:00
|
|
|
ARCH=$(ARCH) \
|
2020-08-19 21:20:40 -04:00
|
|
|
COMMIT_SHA=$(COMMIT_SHA) \
|
2020-01-09 00:58:16 -03:00
|
|
|
REPO_INFO=$(REPO_INFO) \
|
|
|
|
|
TAG=$(TAG) \
|
2022-07-08 12:27:47 -04:00
|
|
|
test/test.sh
|
2017-10-17 19:50:27 -03:00
|
|
|
|
2018-04-23 10:46:28 -04:00
|
|
|
.PHONY: lua-test
|
2020-01-07 10:53:12 -03:00
|
|
|
lua-test: ## Run lua unit tests.
|
2020-01-09 00:58:16 -03:00
|
|
|
@build/run-in-docker.sh \
|
|
|
|
|
BUSTED_ARGS=$(BUSTED_ARGS) \
|
2022-07-08 12:27:47 -04:00
|
|
|
MAC_OS=$(MAC_OS) \
|
|
|
|
|
test/test-lua.sh
|
2018-04-23 10:46:28 -04:00
|
|
|
|
2017-11-12 01:51:41 -03:00
|
|
|
.PHONY: e2e-test
|
2020-06-27 11:57:00 -04:00
|
|
|
e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster).
|
2019-06-27 10:03:20 -04:00
|
|
|
@build/run-e2e-suite.sh
|
2019-02-22 11:03:42 -03:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
.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
|
|
|
|
|
|
2019-02-26 12:32:53 -03:00
|
|
|
.PHONY: e2e-test-binary
|
2020-06-27 11:57:00 -04:00
|
|
|
e2e-test-binary: ## Build binary for e2e tests.
|
2020-01-09 00:58:16 -03:00
|
|
|
@build/run-in-docker.sh \
|
2022-07-08 12:27:47 -04:00
|
|
|
MAC_OS=$(MAC_OS) \
|
2020-01-09 00:58:16 -03:00
|
|
|
ginkgo build ./test/e2e
|
2019-02-22 11:03:42 -03:00
|
|
|
|
2020-02-16 16:28:30 -03:00
|
|
|
.PHONY: print-e2e-suite
|
|
|
|
|
print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests.
|
|
|
|
|
@build/run-in-docker.sh \
|
2022-07-08 12:27:47 -04:00
|
|
|
MAC_OS=$(MAC_OS) \
|
2020-02-16 16:28:30 -03:00
|
|
|
hack/print-e2e-suite.sh
|
|
|
|
|
|
2017-11-12 01:51:41 -03:00
|
|
|
.PHONY: vet
|
2017-10-06 16:58:36 -03:00
|
|
|
vet:
|
2019-05-14 18:59:01 -04:00
|
|
|
@go vet $(shell go list ${PKG}/internal/... | grep -v vendor)
|
2017-06-30 16:19:41 -04:00
|
|
|
|
2017-10-20 22:24:57 -03:00
|
|
|
.PHONY: check_dead_links
|
2020-01-07 10:53:12 -03:00
|
|
|
check_dead_links: ## Check if the documentation contains dead links.
|
2022-04-06 16:46:26 -04:00
|
|
|
@docker run ${PLATFORM_FLAG} ${PLATFORM} -t \
|
|
|
|
|
-w /tmp \
|
|
|
|
|
-v $$PWD:/tmp dkhamsing/awesome_bot:1.20.0 \
|
2018-07-05 23:23:27 -04:00
|
|
|
--allow-dupe \
|
2022-04-06 16:46:26 -04:00
|
|
|
--allow-redirect $(shell find $$PWD -mindepth 1 -name vendor -prune -o -name .modcache -prune -o -iname Changelog.md -prune -o -name "*.md" | sed -e "s#$$PWD/##")
|
2018-04-20 13:47:56 -03:00
|
|
|
|
2018-04-24 16:29:31 -04:00
|
|
|
.PHONY: dev-env
|
2020-06-27 11:57:00 -04:00
|
|
|
dev-env: ## Starts a local Kubernetes cluster using kind, building and deploying the ingress controller.
|
2020-02-12 21:48:41 -03:00
|
|
|
@build/dev-env.sh
|
2018-04-26 18:51:12 -03:00
|
|
|
|
2020-02-19 14:10:28 -03:00
|
|
|
.PHONY: dev-env-stop
|
|
|
|
|
dev-env-stop: ## Deletes local Kubernetes cluster created by kind.
|
|
|
|
|
@kind delete cluster --name ingress-nginx-dev
|
|
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
|
|
|
|
|
|
2018-04-26 18:51:12 -03:00
|
|
|
.PHONY: live-docs
|
2020-09-23 13:33:06 +02:00
|
|
|
live-docs: ## Build and launch a local copy of the documentation website in http://localhost:8000
|
2022-07-26 16:13:10 -04:00
|
|
|
@docker build ${PLATFORM_FLAG} ${PLATFORM} \
|
|
|
|
|
--no-cache \
|
|
|
|
|
$(MAC_DOCKER_FLAGS) \
|
|
|
|
|
-t ingress-nginx-docs .github/actions/mkdocs
|
2022-04-06 16:46:26 -04:00
|
|
|
@docker run ${PLATFORM_FLAG} ${PLATFORM} --rm -it \
|
2020-06-12 16:20:34 -04:00
|
|
|
-p 8000:8000 \
|
|
|
|
|
-v ${PWD}:/docs \
|
2021-01-11 12:53:36 -03:00
|
|
|
--entrypoint mkdocs \
|
|
|
|
|
ingress-nginx-docs serve --dev-addr=0.0.0.0:8000
|
2018-04-26 18:51:12 -03:00
|
|
|
|
2018-08-11 08:26:14 -04:00
|
|
|
.PHONY: misspell
|
2020-06-27 11:57:00 -04:00
|
|
|
misspell: ## Check for spelling errors.
|
2022-01-27 10:52:50 +08:00
|
|
|
@go install github.com/client9/misspell/cmd/misspell@latest
|
2018-08-11 08:26:14 -04:00
|
|
|
misspell \
|
|
|
|
|
-locale US \
|
|
|
|
|
-error \
|
|
|
|
|
cmd/* internal/* deploy/* docs/* design/* test/* README.md
|
2019-05-13 22:31:30 -04:00
|
|
|
|
2019-06-26 08:12:00 -04:00
|
|
|
.PHONY: run-ingress-controller
|
2020-01-07 10:53:12 -03:00
|
|
|
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
|
2019-06-26 08:12:00 -04:00
|
|
|
@build/run-ingress-controller.sh
|
2020-01-09 13:48:43 -03:00
|
|
|
|
2020-06-23 18:05:07 -04:00
|
|
|
.PHONY: ensure-buildx
|
|
|
|
|
ensure-buildx:
|
|
|
|
|
./hack/init-buildx.sh
|
2020-04-24 17:57:51 -04:00
|
|
|
|
|
|
|
|
.PHONY: show-version
|
|
|
|
|
show-version:
|
|
|
|
|
echo -n $(TAG)
|
2020-05-19 17:14:06 -04:00
|
|
|
|
2020-06-01 21:22:32 -04:00
|
|
|
PLATFORMS ?= amd64 arm arm64 s390x
|
2022-07-08 12:27:47 -04:00
|
|
|
BUILDX_PLATFORMS ?= linux/amd64,linux/arm,linux/arm64,linux/s390x
|
2020-06-01 21:22:32 -04:00
|
|
|
|
|
|
|
|
.PHONY: release # Build a multi-arch docker image
|
2020-06-23 18:05:07 -04:00
|
|
|
release: ensure-buildx clean
|
2020-06-01 21:22:32 -04:00
|
|
|
echo "Building binaries..."
|
2020-06-02 16:59:34 -04:00
|
|
|
$(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; ARCH=$(PLATFORM) make build;)
|
2020-06-01 21:22:32 -04:00
|
|
|
|
2022-07-08 12:27:47 -04:00
|
|
|
echo "Building and pushing ingress-nginx image...$(BUILDX_PLATFORMS)"
|
|
|
|
|
|
|
|
|
|
docker buildx build \
|
2020-06-01 21:22:32 -04:00
|
|
|
--no-cache \
|
|
|
|
|
--push \
|
2022-07-08 12:27:47 -04:00
|
|
|
--pull \
|
2020-06-01 21:22:32 -04:00
|
|
|
--progress plain \
|
2022-07-08 12:27:47 -04:00
|
|
|
--platform $(BUILDX_PLATFORMS) \
|
2020-06-01 21:22:32 -04:00
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
|
|
|
|
--build-arg VERSION="$(TAG)" \
|
2020-08-19 21:20:40 -04:00
|
|
|
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
|
2020-08-27 09:18:09 -04:00
|
|
|
--build-arg BUILD_ID="$(BUILD_ID)" \
|
2020-07-08 17:56:50 -04:00
|
|
|
-t $(REGISTRY)/controller:$(TAG) rootfs
|
2022-07-08 12:27:47 -04:00
|
|
|
|
|
|
|
|
docker buildx build \
|
2022-04-09 01:48:04 -03:00
|
|
|
--no-cache \
|
|
|
|
|
--push \
|
2022-07-08 12:27:47 -04:00
|
|
|
--pull \
|
2022-04-09 01:48:04 -03:00
|
|
|
--progress plain \
|
2022-07-08 12:27:47 -04:00
|
|
|
--platform $(BUILDX_PLATFORMS) \
|
2022-04-09 01:48:04 -03:00
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
|
|
|
|
--build-arg VERSION="$(TAG)" \
|
|
|
|
|
--build-arg COMMIT_SHA="$(COMMIT_SHA)" \
|
|
|
|
|
--build-arg BUILD_ID="$(BUILD_ID)" \
|
2022-07-08 12:27:47 -04:00
|
|
|
-t $(REGISTRY)/controller-chroot:$(TAG) rootfs -f rootfs/Dockerfile-chroot
|