2017-10-17 22:50:27 +00: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 13:53:12 +00:00
|
|
|
# Add the following 'help' target to your Makefile
|
|
|
|
# And add help text after each target name starting with '\#\#'
|
|
|
|
|
|
|
|
.DEFAULT_GOAL:=help
|
2016-11-11 01:45:20 +00:00
|
|
|
|
2020-01-09 03:58:16 +00:00
|
|
|
.EXPORT_ALL_VARIABLES:
|
|
|
|
|
|
|
|
ifndef VERBOSE
|
|
|
|
.SILENT:
|
|
|
|
endif
|
|
|
|
|
|
|
|
# set default shell
|
2020-02-16 18:27:39 +00:00
|
|
|
SHELL=/bin/bash -o pipefail -o errexit
|
2020-01-09 03:58:16 +00:00
|
|
|
|
2017-10-06 19:58:36 +00:00
|
|
|
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
|
2020-06-10 18:20:55 +00:00
|
|
|
TAG ?= 0.33.0
|
2018-05-26 16:48:59 +00:00
|
|
|
|
2020-01-09 03:58:16 +00:00
|
|
|
# Use docker to run makefile tasks
|
|
|
|
USE_DOCKER ?= true
|
|
|
|
|
|
|
|
# Disable run docker tasks if running in prow.
|
|
|
|
# only checks the existence of the variable, not the value.
|
|
|
|
ifdef DIND_TASKS
|
|
|
|
USE_DOCKER=false
|
|
|
|
endif
|
|
|
|
|
2018-05-26 16:48:59 +00:00
|
|
|
# e2e settings
|
|
|
|
# Allow limiting the scope of the e2e tests. By default run everything
|
2018-07-06 03:23:27 +00:00
|
|
|
FOCUS ?= .*
|
2018-05-26 16:48:59 +00:00
|
|
|
# number of parallel test
|
2020-06-17 02:29:13 +00:00
|
|
|
E2E_NODES ?= 10
|
2019-02-22 14:03:42 +00:00
|
|
|
# slow test only if takes > 50s
|
|
|
|
SLOW_E2E_THRESHOLD ?= 50
|
2020-01-07 13:53:12 +00:00
|
|
|
# run e2e test suite with tests that check for memory leaks? (default is false)
|
2019-06-27 14:03:20 +00:00
|
|
|
E2E_CHECK_LEAKS ?=
|
|
|
|
|
2019-05-14 02:31:30 +00:00
|
|
|
REPO_INFO ?= $(shell git config --get remote.origin.url)
|
|
|
|
GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
|
2016-11-11 01:45:20 +00:00
|
|
|
|
2018-07-06 03:23:27 +00:00
|
|
|
PKG = k8s.io/ingress-nginx
|
2016-11-11 01:45:20 +00:00
|
|
|
|
2020-03-19 11:06:12 +00: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 14:33:16 +00:00
|
|
|
|
2020-01-07 13:53:12 +00:00
|
|
|
REGISTRY ?= quay.io/kubernetes-ingress-controller
|
2019-06-26 12:12:00 +00:00
|
|
|
|
2020-06-02 19:41:56 +00:00
|
|
|
BASE_IMAGE ?= quay.io/kubernetes-ingress-controller/nginx:e3c49c52f4b74fe47ad65d6f3266a02e8b6b622f
|
2020-01-07 13:53:12 +00:00
|
|
|
|
2020-02-01 01:56:55 +00:00
|
|
|
GOARCH=$(ARCH)
|
2020-01-09 03:58:16 +00:00
|
|
|
|
2020-01-07 13:53:12 +00:00
|
|
|
help: ## Display this help
|
|
|
|
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
|
2020-05-31 03:25:56 +00:00
|
|
|
.PHONY: image
|
2020-06-02 01:22:32 +00:00
|
|
|
image: clean-image ## Build image for a particular arch.
|
2020-01-26 13:07:55 +00:00
|
|
|
echo "Building docker image ($(ARCH))..."
|
2020-06-02 01:22:32 +00:00
|
|
|
@docker build \
|
2020-01-26 13:07:55 +00:00
|
|
|
--no-cache \
|
2020-05-29 22:31:13 +00:00
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
2020-02-01 01:56:55 +00:00
|
|
|
--build-arg VERSION="$(TAG)" \
|
2020-06-02 01:22:32 +00:00
|
|
|
--build-arg TARGETARCH="$(ARCH)" \
|
|
|
|
-t $(REGISTRY)/nginx-ingress-controller:$(TAG) rootfs
|
2017-10-06 19:58:36 +00:00
|
|
|
|
2020-05-31 03:25:56 +00:00
|
|
|
.PHONY: clean-image
|
|
|
|
clean-image: ## Removes local image
|
2020-06-17 15:24:28 +00:00
|
|
|
echo "removing old image $(REGISTRY)/nginx-ingress-controller:$(TAG)"
|
|
|
|
@docker rmi -f $(REGISTRY)/nginx-ingress-controller:$(TAG) || true
|
2020-04-28 23:42:11 +00:00
|
|
|
|
2017-11-12 04:51:41 +00:00
|
|
|
.PHONY: build
|
2020-01-09 16:48:43 +00:00
|
|
|
build: check-go-version ## Build ingress controller, debug tool and pre-stop hook.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
PKG=$(PKG) \
|
2020-01-09 16:48:43 +00:00
|
|
|
ARCH=$(ARCH) \
|
2020-01-09 03:58:16 +00:00
|
|
|
GIT_COMMIT=$(GIT_COMMIT) \
|
|
|
|
REPO_INFO=$(REPO_INFO) \
|
|
|
|
TAG=$(TAG) \
|
|
|
|
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
|
|
|
|
build/build.sh
|
|
|
|
else
|
2019-05-14 22:59:01 +00:00
|
|
|
@build/build.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2018-07-06 03:23:27 +00:00
|
|
|
|
2019-02-25 20:54:00 +00:00
|
|
|
.PHONY: build-plugin
|
2020-01-09 16:48:43 +00:00
|
|
|
build-plugin: check-go-version ## Build ingress-nginx krew plugin.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
PKG=$(PKG) \
|
2020-01-09 16:48:43 +00:00
|
|
|
ARCH=$(ARCH) \
|
2020-01-09 03:58:16 +00:00
|
|
|
GIT_COMMIT=$(GIT_COMMIT) \
|
|
|
|
REPO_INFO=$(REPO_INFO) \
|
|
|
|
TAG=$(TAG) \
|
|
|
|
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
|
|
|
|
build/build-plugin.sh
|
|
|
|
else
|
2019-05-14 22:59:01 +00:00
|
|
|
@build/build-plugin.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2019-02-25 20:54:00 +00:00
|
|
|
|
2018-08-02 20:58:58 +00:00
|
|
|
.PHONY: clean
|
2020-01-07 13:53:12 +00:00
|
|
|
clean: ## Remove .gocache directory.
|
2020-02-16 14:27:57 +00:00
|
|
|
rm -rf bin/ .gocache/ .cache/
|
2016-11-11 01:45:20 +00:00
|
|
|
|
2018-07-06 03:23:27 +00:00
|
|
|
.PHONY: static-check
|
2020-02-26 00:14:21 +00:00
|
|
|
static-check: ## Run verification script for boilerplate, codegen, gofmt, golint, lualint and chart-lint.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
2020-02-26 00:14:21 +00:00
|
|
|
hack/verify-all.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
else
|
2020-02-26 00:14:21 +00:00
|
|
|
@hack/verify-all.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2017-10-06 19:58:36 +00:00
|
|
|
|
2017-11-12 04:51:41 +00:00
|
|
|
.PHONY: test
|
2020-01-09 16:48:43 +00:00
|
|
|
test: check-go-version ## Run go unit tests.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
PKG=$(PKG) \
|
2020-01-09 16:48:43 +00:00
|
|
|
ARCH=$(ARCH) \
|
2020-01-09 03:58:16 +00:00
|
|
|
GIT_COMMIT=$(GIT_COMMIT) \
|
|
|
|
REPO_INFO=$(REPO_INFO) \
|
|
|
|
TAG=$(TAG) \
|
|
|
|
GOBUILD_FLAGS=$(GOBUILD_FLAGS) \
|
|
|
|
build/test.sh
|
|
|
|
else
|
2019-05-14 22:59:01 +00:00
|
|
|
@build/test.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2017-10-17 22:50:27 +00:00
|
|
|
|
2018-04-23 14:46:28 +00:00
|
|
|
.PHONY: lua-test
|
2020-01-07 13:53:12 +00:00
|
|
|
lua-test: ## Run lua unit tests.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
BUSTED_ARGS=$(BUSTED_ARGS) \
|
|
|
|
build/test-lua.sh
|
|
|
|
else
|
2019-05-14 22:59:01 +00:00
|
|
|
@build/test-lua.sh
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2018-04-23 14:46:28 +00:00
|
|
|
|
2017-11-12 04:51:41 +00:00
|
|
|
.PHONY: e2e-test
|
2020-01-09 16:48:43 +00:00
|
|
|
e2e-test: check-go-version ## Run e2e tests (expects access to a working Kubernetes cluster).
|
2019-06-27 14:03:20 +00:00
|
|
|
@build/run-e2e-suite.sh
|
2019-02-22 14:03:42 +00:00
|
|
|
|
2019-02-26 15:32:53 +00:00
|
|
|
.PHONY: e2e-test-binary
|
2020-01-09 16:48:43 +00:00
|
|
|
e2e-test-binary: check-go-version ## Build ginkgo binary for e2e tests.
|
2020-01-09 03:58:16 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
ginkgo build ./test/e2e
|
|
|
|
else
|
2019-05-14 22:59:01 +00:00
|
|
|
@ginkgo build ./test/e2e
|
2020-01-09 03:58:16 +00:00
|
|
|
endif
|
2019-02-22 14:03:42 +00:00
|
|
|
|
2020-02-16 19:28:30 +00:00
|
|
|
.PHONY: print-e2e-suite
|
|
|
|
print-e2e-suite: e2e-test-binary ## Prints information about the suite of e2e tests.
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
hack/print-e2e-suite.sh
|
|
|
|
|
2017-11-12 04:51:41 +00:00
|
|
|
.PHONY: cover
|
2020-01-09 16:48:43 +00:00
|
|
|
cover: check-go-version ## Run go coverage unit tests.
|
2019-05-14 22:59:01 +00:00
|
|
|
@build/cover.sh
|
2018-07-06 03:23:27 +00:00
|
|
|
echo "Uploading coverage results..."
|
2019-05-14 22:59:01 +00:00
|
|
|
@curl -s https://codecov.io/bash | bash
|
2016-12-15 12:50:02 +00:00
|
|
|
|
2017-11-12 04:51:41 +00:00
|
|
|
.PHONY: vet
|
2017-10-06 19:58:36 +00:00
|
|
|
vet:
|
2019-05-14 22:59:01 +00:00
|
|
|
@go vet $(shell go list ${PKG}/internal/... | grep -v vendor)
|
2017-06-30 20:19:41 +00:00
|
|
|
|
2017-10-21 01:24:57 +00:00
|
|
|
.PHONY: check_dead_links
|
2020-01-07 13:53:12 +00:00
|
|
|
check_dead_links: ## Check if the documentation contains dead links.
|
2019-05-14 22:59:01 +00:00
|
|
|
@docker run -t \
|
2018-07-06 03:23:27 +00:00
|
|
|
-v $$PWD:/tmp aledbf/awesome_bot:0.1 \
|
|
|
|
--allow-dupe \
|
|
|
|
--allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md)
|
2018-04-20 16:47:56 +00:00
|
|
|
|
2018-04-24 20:29:31 +00:00
|
|
|
.PHONY: dev-env
|
2020-02-19 17:10:28 +00:00
|
|
|
dev-env: check-go-version ## Starts a local Kubernetes cluster using kind, building and deploying the ingress controller.
|
2020-02-13 00:48:41 +00:00
|
|
|
@build/dev-env.sh
|
2018-04-26 21:51:12 +00:00
|
|
|
|
2020-02-19 17:10:28 +00:00
|
|
|
.PHONY: dev-env-stop
|
|
|
|
dev-env-stop: ## Deletes local Kubernetes cluster created by kind.
|
|
|
|
@kind delete cluster --name ingress-nginx-dev
|
|
|
|
|
2018-04-26 21:51:12 +00:00
|
|
|
.PHONY: live-docs
|
2020-01-07 13:53:12 +00:00
|
|
|
live-docs: ## Build and launch a local copy of the documentation website in http://localhost:3000
|
2020-06-12 20:20:34 +00:00
|
|
|
@docker run --rm -it \
|
|
|
|
-p 8000:8000 \
|
|
|
|
-v ${PWD}:/docs \
|
|
|
|
squidfunk/mkdocs-material:5.2.3
|
2018-04-26 21:51:12 +00:00
|
|
|
|
2018-08-11 12:26:14 +00:00
|
|
|
.PHONY: misspell
|
2020-01-09 16:48:43 +00:00
|
|
|
misspell: check-go-version ## Check for spelling errors.
|
2019-05-14 22:59:01 +00:00
|
|
|
@go get github.com/client9/misspell/cmd/misspell
|
2018-08-11 12:26:14 +00:00
|
|
|
misspell \
|
|
|
|
-locale US \
|
|
|
|
-error \
|
|
|
|
cmd/* internal/* deploy/* docs/* design/* test/* README.md
|
2019-05-14 02:31:30 +00:00
|
|
|
|
2019-06-26 12:12:00 +00:00
|
|
|
.PHONY: kind-e2e-test
|
2020-01-09 16:48:43 +00:00
|
|
|
kind-e2e-test: check-go-version ## Run e2e tests using kind.
|
2020-02-13 14:48:32 +00:00
|
|
|
@test/e2e/run.sh
|
2019-06-26 12:12:00 +00:00
|
|
|
|
2020-04-16 00:26:08 +00:00
|
|
|
.PHONY: kind-e2e-chart-tests
|
|
|
|
kind-e2e-chart-tests: ## Run helm chart e2e tests
|
|
|
|
@test/e2e/run-chart-test.sh
|
|
|
|
|
2019-06-26 12:12:00 +00:00
|
|
|
.PHONY: run-ingress-controller
|
2020-01-07 13:53:12 +00:00
|
|
|
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
|
2019-06-26 12:12:00 +00:00
|
|
|
@build/run-ingress-controller.sh
|
2020-01-09 16:48:43 +00:00
|
|
|
|
|
|
|
.PHONY: check-go-version
|
|
|
|
check-go-version:
|
2020-03-19 00:00:37 +00:00
|
|
|
ifeq ($(USE_DOCKER), true)
|
|
|
|
@build/run-in-docker.sh \
|
|
|
|
hack/check-go-version.sh
|
|
|
|
else
|
2020-01-09 16:48:43 +00:00
|
|
|
@hack/check-go-version.sh
|
2020-03-19 00:00:37 +00:00
|
|
|
endif
|
2020-01-26 13:07:55 +00:00
|
|
|
|
2020-06-23 22:05:07 +00:00
|
|
|
.PHONY: ensure-buildx
|
|
|
|
ensure-buildx:
|
2020-01-26 13:07:55 +00:00
|
|
|
ifeq ($(DIND_TASKS),)
|
2020-06-23 22:05:07 +00:00
|
|
|
./hack/init-buildx.sh
|
2020-01-26 13:07:55 +00:00
|
|
|
endif
|
2020-04-24 21:57:51 +00:00
|
|
|
|
|
|
|
.PHONY: show-version
|
|
|
|
show-version:
|
|
|
|
echo -n $(TAG)
|
2020-05-19 21:14:06 +00:00
|
|
|
|
2020-06-02 01:22:32 +00:00
|
|
|
PLATFORMS ?= amd64 arm arm64 s390x
|
|
|
|
|
|
|
|
EMPTY :=
|
|
|
|
SPACE := $(EMPTY) $(EMPTY)
|
|
|
|
COMMA := ,
|
|
|
|
|
|
|
|
.PHONY: release # Build a multi-arch docker image
|
2020-06-23 22:05:07 +00:00
|
|
|
release: ensure-buildx clean
|
2020-06-02 01:22:32 +00:00
|
|
|
echo "Building binaries..."
|
2020-06-02 20:59:34 +00:00
|
|
|
$(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; ARCH=$(PLATFORM) make build;)
|
2020-06-02 01:22:32 +00:00
|
|
|
|
|
|
|
echo "Building and pushing ingress-nginx image..."
|
|
|
|
@docker buildx build \
|
|
|
|
--no-cache \
|
|
|
|
--push \
|
|
|
|
--progress plain \
|
|
|
|
--platform $(subst $(SPACE),$(COMMA),$(PLATFORMS)) \
|
|
|
|
--build-arg BASE_IMAGE="$(BASE_IMAGE)" \
|
|
|
|
--build-arg VERSION="$(TAG)" \
|
|
|
|
-t $(REGISTRY)/nginx-ingress-controller:$(TAG) rootfs
|