parent
0a7913a45a
commit
5f6c4cff3e
3 changed files with 52 additions and 50 deletions
94
Makefile
94
Makefile
|
@ -12,15 +12,14 @@
|
||||||
# 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.
|
||||||
|
|
||||||
.PHONY: all
|
# Add the following 'help' target to your Makefile
|
||||||
all: all-container
|
# And add help text after each target name starting with '\#\#'
|
||||||
|
|
||||||
|
.DEFAULT_GOAL:=help
|
||||||
|
|
||||||
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
|
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
|
||||||
TAG ?= master
|
TAG ?= master
|
||||||
REGISTRY ?= quay.io/kubernetes-ingress-controller
|
|
||||||
DOCKER ?= docker
|
DOCKER ?= docker
|
||||||
SED_I ?= sed -i
|
|
||||||
GOHOSTOS ?= $(shell go env GOHOSTOS)
|
|
||||||
|
|
||||||
# e2e settings
|
# e2e settings
|
||||||
# Allow limiting the scope of the e2e tests. By default run everything
|
# Allow limiting the scope of the e2e tests. By default run everything
|
||||||
|
@ -29,10 +28,11 @@ FOCUS ?= .*
|
||||||
E2E_NODES ?= 10
|
E2E_NODES ?= 10
|
||||||
# slow test only if takes > 50s
|
# slow test only if takes > 50s
|
||||||
SLOW_E2E_THRESHOLD ?= 50
|
SLOW_E2E_THRESHOLD ?= 50
|
||||||
K8S_VERSION ?= v1.14.1
|
# run e2e test suite with tests that check for memory leaks? (default is false)
|
||||||
|
|
||||||
E2E_CHECK_LEAKS ?=
|
E2E_CHECK_LEAKS ?=
|
||||||
|
|
||||||
|
# fix sed for osx
|
||||||
|
SED_I ?= sed -i
|
||||||
ifeq ($(GOHOSTOS),darwin)
|
ifeq ($(GOHOSTOS),darwin)
|
||||||
SED_I=sed -i ''
|
SED_I=sed -i ''
|
||||||
endif
|
endif
|
||||||
|
@ -42,21 +42,20 @@ GIT_COMMIT ?= git-$(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
PKG = k8s.io/ingress-nginx
|
PKG = k8s.io/ingress-nginx
|
||||||
|
|
||||||
ARCH ?= $(shell go env GOARCH)
|
|
||||||
GOARCH = ${ARCH}
|
|
||||||
|
|
||||||
|
|
||||||
GOBUILD_FLAGS := -v
|
|
||||||
|
|
||||||
ALL_ARCH = amd64 arm arm64
|
ALL_ARCH = amd64 arm arm64
|
||||||
|
|
||||||
QEMUVERSION = v4.1.1-1
|
|
||||||
|
|
||||||
BUSTED_ARGS =-v --pattern=_test
|
BUSTED_ARGS =-v --pattern=_test
|
||||||
|
|
||||||
|
ARCH ?= $(shell go env GOARCH)
|
||||||
|
|
||||||
|
REGISTRY ?= quay.io/kubernetes-ingress-controller
|
||||||
|
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}
|
||||||
|
|
||||||
|
GOHOSTOS ?= $(shell go env GOHOSTOS)
|
||||||
|
GOARCH = ${ARCH}
|
||||||
GOOS = linux
|
GOOS = linux
|
||||||
|
|
||||||
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}
|
GOBUILD_FLAGS := -v
|
||||||
|
|
||||||
# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules
|
# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules
|
||||||
GO111MODULE=off
|
GO111MODULE=off
|
||||||
|
@ -90,23 +89,29 @@ TEMP_DIR := $(shell mktemp -d)
|
||||||
|
|
||||||
DOCKERFILE := $(TEMP_DIR)/rootfs/Dockerfile
|
DOCKERFILE := $(TEMP_DIR)/rootfs/Dockerfile
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# internal task
|
||||||
.PHONY: sub-container-%
|
.PHONY: sub-container-%
|
||||||
sub-container-%:
|
sub-container-%:
|
||||||
$(MAKE) ARCH=$* build container
|
$(MAKE) ARCH=$* build container
|
||||||
|
|
||||||
|
# internal task
|
||||||
.PHONY: sub-push-%
|
.PHONY: sub-push-%
|
||||||
sub-push-%:
|
sub-push-%: ## Publish image for a particular arch.
|
||||||
$(MAKE) ARCH=$* push
|
$(MAKE) ARCH=$* push
|
||||||
|
|
||||||
.PHONY: all-container
|
.PHONY: all-container
|
||||||
all-container: $(addprefix sub-container-,$(ALL_ARCH))
|
all-container: $(addprefix sub-container-,$(ALL_ARCH)) ## Build image for amd64, arm and arm64.
|
||||||
|
|
||||||
.PHONY: all-push
|
.PHONY: all-push
|
||||||
all-push: $(addprefix sub-push-,$(ALL_ARCH))
|
all-push: $(addprefix sub-push-,$(ALL_ARCH)) ## Publish images for amd64, arm and arm64.
|
||||||
|
|
||||||
.PHONY: container
|
.PHONY: container
|
||||||
container: clean-container .container-$(ARCH)
|
container: clean-container .container-$(ARCH) ## Build image for a particular arch.
|
||||||
|
|
||||||
|
# internal task to build image for a particular arch.
|
||||||
.PHONY: .container-$(ARCH)
|
.PHONY: .container-$(ARCH)
|
||||||
.container-$(ARCH):
|
.container-$(ARCH):
|
||||||
mkdir -p $(TEMP_DIR)/rootfs
|
mkdir -p $(TEMP_DIR)/rootfs
|
||||||
|
@ -124,68 +129,67 @@ ifeq ($(ARCH),amd64)
|
||||||
$(SED_I) "/CROSS_BUILD_/d" $(DOCKERFILE)
|
$(SED_I) "/CROSS_BUILD_/d" $(DOCKERFILE)
|
||||||
else
|
else
|
||||||
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
|
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
|
||||||
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR)/rootfs
|
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/v4.1.1-1/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR)/rootfs
|
||||||
$(SED_I) "s/CROSS_BUILD_//g" $(DOCKERFILE)
|
$(SED_I) "s/CROSS_BUILD_//g" $(DOCKERFILE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
echo "Building docker image..."
|
echo "Building docker image..."
|
||||||
$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMAGE):$(TAG) $(TEMP_DIR)/rootfs
|
$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMAGE):$(TAG) $(TEMP_DIR)/rootfs
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean-container
|
.PHONY: clean-container
|
||||||
clean-container:
|
clean-container: ## Removes local image
|
||||||
@$(DOCKER) rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true
|
@$(DOCKER) rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true
|
||||||
|
|
||||||
.PHONY: register-qemu
|
.PHONY: register-qemu
|
||||||
register-qemu:
|
register-qemu: ## Register /usr/bin/qemu-ARCH-static as the handler for binaries in multiple platforms
|
||||||
# Register /usr/bin/qemu-ARCH-static as the handler for binaries in multiple platforms
|
|
||||||
@$(DOCKER) run --rm --privileged multiarch/qemu-user-static:register --reset >&2
|
@$(DOCKER) run --rm --privileged multiarch/qemu-user-static:register --reset >&2
|
||||||
|
|
||||||
.PHONY: push
|
.PHONY: push
|
||||||
push: .push-$(ARCH)
|
push: .push-$(ARCH) ## Publish image for a particular arch.
|
||||||
|
|
||||||
|
# internal task
|
||||||
.PHONY: .push-$(ARCH)
|
.PHONY: .push-$(ARCH)
|
||||||
.push-$(ARCH):
|
.push-$(ARCH):
|
||||||
$(DOCKER) push $(MULTI_ARCH_IMAGE):$(TAG)
|
$(DOCKER) push $(MULTI_ARCH_IMAGE):$(TAG)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build: ## Build ingress controller, debug tool and pre-stop hook.
|
||||||
@build/build.sh
|
@build/build.sh
|
||||||
|
|
||||||
.PHONY: build-plugin
|
.PHONY: build-plugin
|
||||||
build-plugin:
|
build-plugin: ## Build ingress-nginx krew plugin.
|
||||||
@build/build-plugin.sh
|
@build/build-plugin.sh
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean: ## Remove .gocache directory.
|
||||||
rm -rf bin/ .gocache/
|
rm -rf bin/ .gocache/
|
||||||
|
|
||||||
.PHONY: static-check
|
.PHONY: static-check
|
||||||
static-check:
|
static-check: ## Run verification script for boilerplate, codegen, gofmt, golint and lualint.
|
||||||
@build/static-check.sh
|
@build/static-check.sh
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test: ## Run go unit tests.
|
||||||
@build/test.sh
|
@build/test.sh
|
||||||
|
|
||||||
.PHONY: lua-test
|
.PHONY: lua-test
|
||||||
lua-test:
|
lua-test: ## Run lua unit tests.
|
||||||
@build/test-lua.sh
|
@build/test-lua.sh
|
||||||
|
|
||||||
.PHONY: e2e-test
|
.PHONY: e2e-test
|
||||||
e2e-test:
|
e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster).
|
||||||
@build/run-e2e-suite.sh
|
@build/run-e2e-suite.sh
|
||||||
|
|
||||||
.PHONY: e2e-test-image
|
.PHONY: e2e-test-image
|
||||||
e2e-test-image: e2e-test-binary
|
e2e-test-image: e2e-test-binary ## Build image for e2e tests.
|
||||||
make -C test/e2e-image
|
make -C test/e2e-image
|
||||||
|
|
||||||
.PHONY: e2e-test-binary
|
.PHONY: e2e-test-binary
|
||||||
e2e-test-binary:
|
e2e-test-binary: ## Build ginkgo binary for e2e tests.
|
||||||
@ginkgo build ./test/e2e
|
@ginkgo build ./test/e2e
|
||||||
|
|
||||||
.PHONY: cover
|
.PHONY: cover
|
||||||
cover:
|
cover: ## Run go coverage unit tests.
|
||||||
@build/cover.sh
|
@build/cover.sh
|
||||||
echo "Uploading coverage results..."
|
echo "Uploading coverage results..."
|
||||||
@curl -s https://codecov.io/bash | bash
|
@curl -s https://codecov.io/bash | bash
|
||||||
|
@ -195,38 +199,38 @@ vet:
|
||||||
@go vet $(shell go list ${PKG}/internal/... | grep -v vendor)
|
@go vet $(shell go list ${PKG}/internal/... | grep -v vendor)
|
||||||
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
release: all-container all-push
|
release: all-container all-push ## Build and publish images of the ingress controller.
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
.PHONY: check_dead_links
|
.PHONY: check_dead_links
|
||||||
check_dead_links:
|
check_dead_links: ## Check if the documentation contains dead links.
|
||||||
@docker run -t \
|
@docker run -t \
|
||||||
-v $$PWD:/tmp aledbf/awesome_bot:0.1 \
|
-v $$PWD:/tmp aledbf/awesome_bot:0.1 \
|
||||||
--allow-dupe \
|
--allow-dupe \
|
||||||
--allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md)
|
--allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md)
|
||||||
|
|
||||||
.PHONY: dep-ensure
|
.PHONY: dep-ensure
|
||||||
dep-ensure:
|
dep-ensure: ## Update and vendo go dependencies.
|
||||||
go mod tidy -v
|
go mod tidy -v
|
||||||
find vendor -name '*_test.go' -delete
|
find vendor -name '*_test.go' -delete
|
||||||
go mod vendor
|
go mod vendor
|
||||||
|
|
||||||
.PHONY: dev-env
|
.PHONY: dev-env
|
||||||
dev-env:
|
dev-env: ## Starts a local Kubernetes cluster using minikube, building and deploying the ingress controller.
|
||||||
@build/dev-env.sh
|
@build/dev-env.sh
|
||||||
|
|
||||||
.PHONY: live-docs
|
.PHONY: live-docs
|
||||||
live-docs:
|
live-docs: ## Build and launch a local copy of the documentation website in http://localhost:3000
|
||||||
@docker build --pull -t ingress-nginx/mkdocs images/mkdocs
|
@docker build --pull -t ingress-nginx/mkdocs images/mkdocs
|
||||||
@docker run --rm -it -p 3000:3000 -v ${PWD}:/docs ingress-nginx/mkdocs
|
@docker run --rm -it -p 3000:3000 -v ${PWD}:/docs ingress-nginx/mkdocs
|
||||||
|
|
||||||
.PHONY: build-docs
|
.PHONY: build-docs
|
||||||
build-docs:
|
build-docs: ## Build documentation (output in ./site directory).
|
||||||
@docker build --pull -t ingress-nginx/mkdocs images/mkdocs
|
@docker build --pull -t ingress-nginx/mkdocs images/mkdocs
|
||||||
@docker run --rm -v ${PWD}:/docs ingress-nginx/mkdocs build
|
@docker run --rm -v ${PWD}:/docs ingress-nginx/mkdocs build
|
||||||
|
|
||||||
.PHONY: misspell
|
.PHONY: misspell
|
||||||
misspell:
|
misspell: ## Check for spelling errors.
|
||||||
@go get github.com/client9/misspell/cmd/misspell
|
@go get github.com/client9/misspell/cmd/misspell
|
||||||
misspell \
|
misspell \
|
||||||
-locale US \
|
-locale US \
|
||||||
|
@ -234,9 +238,9 @@ misspell:
|
||||||
cmd/* internal/* deploy/* docs/* design/* test/* README.md
|
cmd/* internal/* deploy/* docs/* design/* test/* README.md
|
||||||
|
|
||||||
.PHONY: kind-e2e-test
|
.PHONY: kind-e2e-test
|
||||||
kind-e2e-test:
|
kind-e2e-test: ## Run e2e tests using kind.
|
||||||
test/e2e/run.sh
|
test/e2e/run.sh
|
||||||
|
|
||||||
.PHONY: run-ingress-controller
|
.PHONY: run-ingress-controller
|
||||||
run-ingress-controller:
|
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
|
||||||
@build/run-ingress-controller.sh
|
@build/run-ingress-controller.sh
|
||||||
|
|
|
@ -44,7 +44,7 @@ type Config struct {
|
||||||
AuthSnippet string `json:"authSnippet"`
|
AuthSnippet string `json:"authSnippet"`
|
||||||
AuthCacheKey string `json:"authCacheKey"`
|
AuthCacheKey string `json:"authCacheKey"`
|
||||||
AuthCacheDuration []string `json:"authCacheDuration"`
|
AuthCacheDuration []string `json:"authCacheDuration"`
|
||||||
ProxySetHeaders map[string]string `json:"proxySetHeaders",omitempty`
|
ProxySetHeaders map[string]string `json:"proxySetHeaders,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultCacheDuration is the fallback value if no cache duration is provided
|
// DefaultCacheDuration is the fallback value if no cache duration is provided
|
||||||
|
|
|
@ -923,7 +923,7 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
},
|
},
|
||||||
"valid ingress definition with name validIng in namespace default": {
|
"valid ingress definition with name validIng in namespace default": {
|
||||||
&ingress.Ingress{
|
&ingress.Ingress{
|
||||||
networking.Ingress{
|
Ingress: networking.Ingress{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "validIng",
|
Name: "validIng",
|
||||||
Namespace: apiv1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
|
@ -937,7 +937,6 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nil,
|
|
||||||
},
|
},
|
||||||
"host1",
|
"host1",
|
||||||
"",
|
"",
|
||||||
|
@ -952,7 +951,7 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
},
|
},
|
||||||
"valid ingress definition with name demo in namespace something and path /ok using a service with name b-svc port 80": {
|
"valid ingress definition with name demo in namespace something and path /ok using a service with name b-svc port 80": {
|
||||||
&ingress.Ingress{
|
&ingress.Ingress{
|
||||||
networking.Ingress{
|
Ingress: networking.Ingress{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
Namespace: "something",
|
Namespace: "something",
|
||||||
|
@ -982,7 +981,6 @@ func TestGetIngressInformation(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nil,
|
|
||||||
},
|
},
|
||||||
"foo.bar",
|
"foo.bar",
|
||||||
"/ok",
|
"/ok",
|
||||||
|
|
Loading…
Reference in a new issue