Merge pull request #4299 from aledbf/cleanup
Fix scripts to be able to run tests in docker
This commit is contained in:
commit
84af99b512
8 changed files with 45 additions and 41 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -47,3 +47,5 @@ gh-pages
|
||||||
/bin/
|
/bin/
|
||||||
|
|
||||||
test/e2e-image/wait-for-nginx\.sh
|
test/e2e-image/wait-for-nginx\.sh
|
||||||
|
|
||||||
|
.cache
|
||||||
|
|
23
Makefile
23
Makefile
|
@ -44,7 +44,7 @@ PKG = k8s.io/ingress-nginx
|
||||||
|
|
||||||
ARCH ?= $(shell go env GOARCH)
|
ARCH ?= $(shell go env GOARCH)
|
||||||
GOARCH = ${ARCH}
|
GOARCH = ${ARCH}
|
||||||
DUMB_ARCH = ${ARCH}
|
|
||||||
|
|
||||||
GOBUILD_FLAGS := -v
|
GOBUILD_FLAGS := -v
|
||||||
|
|
||||||
|
@ -56,13 +56,9 @@ BUSTED_ARGS =-v --pattern=_test
|
||||||
|
|
||||||
GOOS = linux
|
GOOS = linux
|
||||||
|
|
||||||
IMGNAME = nginx-ingress-controller
|
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}
|
||||||
IMAGE = $(REGISTRY)/$(IMGNAME)
|
|
||||||
|
|
||||||
MULTI_ARCH_IMG = ${IMAGE}-${ARCH}
|
|
||||||
|
|
||||||
export ARCH
|
export ARCH
|
||||||
export DUMB_ARCH
|
|
||||||
export TAG
|
export TAG
|
||||||
export PKG
|
export PKG
|
||||||
export GOARCH
|
export GOARCH
|
||||||
|
@ -116,7 +112,6 @@ container: clean-container .container-$(ARCH)
|
||||||
cp -RP ./* $(TEMP_DIR)
|
cp -RP ./* $(TEMP_DIR)
|
||||||
$(SED_I) "s|BASEIMAGE|$(BASEIMAGE)|g" $(DOCKERFILE)
|
$(SED_I) "s|BASEIMAGE|$(BASEIMAGE)|g" $(DOCKERFILE)
|
||||||
$(SED_I) "s|QEMUARCH|$(QEMUARCH)|g" $(DOCKERFILE)
|
$(SED_I) "s|QEMUARCH|$(QEMUARCH)|g" $(DOCKERFILE)
|
||||||
$(SED_I) "s|DUMB_ARCH|$(DUMB_ARCH)|g" $(DOCKERFILE)
|
|
||||||
|
|
||||||
ifeq ($(ARCH),amd64)
|
ifeq ($(ARCH),amd64)
|
||||||
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
|
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
|
||||||
|
@ -127,16 +122,13 @@ else
|
||||||
$(SED_I) "s/CROSS_BUILD_//g" $(DOCKERFILE)
|
$(SED_I) "s/CROSS_BUILD_//g" $(DOCKERFILE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR)/rootfs
|
echo "Building docker image..."
|
||||||
|
$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMAGE):$(TAG) $(TEMP_DIR)/rootfs
|
||||||
|
|
||||||
ifeq ($(ARCH), amd64)
|
|
||||||
# This is for maintaining backward compatibility
|
|
||||||
@$(DOCKER) tag $(MULTI_ARCH_IMG):$(TAG) $(IMAGE):$(TAG)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: clean-container
|
.PHONY: clean-container
|
||||||
clean-container:
|
clean-container:
|
||||||
@$(DOCKER) rmi -f $(MULTI_ARCH_IMG):$(TAG) || true
|
@$(DOCKER) rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true
|
||||||
|
|
||||||
.PHONY: register-qemu
|
.PHONY: register-qemu
|
||||||
register-qemu:
|
register-qemu:
|
||||||
|
@ -148,10 +140,7 @@ push: .push-$(ARCH)
|
||||||
|
|
||||||
.PHONY: .push-$(ARCH)
|
.PHONY: .push-$(ARCH)
|
||||||
.push-$(ARCH):
|
.push-$(ARCH):
|
||||||
$(DOCKER) push $(MULTI_ARCH_IMG):$(TAG)
|
$(DOCKER) push $(MULTI_ARCH_IMAGE):$(TAG)
|
||||||
ifeq ($(ARCH), amd64)
|
|
||||||
$(DOCKER) push $(IMAGE):$(TAG)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -22,10 +22,20 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# temporal directory for the fake SSL certificate
|
||||||
|
SSL_VOLUME=$(mktemp -d)
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
rm -rf "${SSL_VOLUME}"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v06262019-ecce3fd7b
|
E2E_IMAGE=quay.io/kubernetes-ingress-controller/e2e:v06262019-ecce3fd7b
|
||||||
|
|
||||||
DOCKER_OPTS=${DOCKER_OPTS:-}
|
DOCKER_OPTS=${DOCKER_OPTS:-}
|
||||||
|
|
||||||
|
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd -P)
|
||||||
|
|
||||||
FLAGS=$@
|
FLAGS=$@
|
||||||
|
|
||||||
PKG=k8s.io/ingress-nginx
|
PKG=k8s.io/ingress-nginx
|
||||||
|
@ -42,11 +52,12 @@ docker run \
|
||||||
--tty \
|
--tty \
|
||||||
--rm \
|
--rm \
|
||||||
${DOCKER_OPTS} \
|
${DOCKER_OPTS} \
|
||||||
|
-e GOCACHE="/go/src/${PKG}/.cache" \
|
||||||
-v "${HOME}/.kube:${HOME}/.kube" \
|
-v "${HOME}/.kube:${HOME}/.kube" \
|
||||||
-v "${PWD}:/go/src/${PKG}" \
|
-v "${KUBE_ROOT}:/go/src/${PKG}" \
|
||||||
-v "${PWD}/.gocache:${HOME}/.cache/go-build" \
|
-v "${KUBE_ROOT}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
|
||||||
-v "${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
|
|
||||||
-v "/var/run/docker.sock:/var/run/docker.sock" \
|
-v "/var/run/docker.sock:/var/run/docker.sock" \
|
||||||
|
-v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \
|
||||||
${MINIKUBE_VOLUME} \
|
${MINIKUBE_VOLUME} \
|
||||||
-w "/go/src/${PKG}" \
|
-w "/go/src/${PKG}" \
|
||||||
-u $(id -u ${USER}):$(id -g ${USER}) \
|
-u $(id -u ${USER}):$(id -g ${USER}) \
|
||||||
|
|
|
@ -62,6 +62,7 @@ POD_NAMESPACE="invalid-namespace"
|
||||||
POD_NAME="invalid-namespace"
|
POD_NAME="invalid-namespace"
|
||||||
|
|
||||||
export TAG=local
|
export TAG=local
|
||||||
|
export IMAGE
|
||||||
|
|
||||||
if [[ "${ARCH}" != "amd64" ]]; then
|
if [[ "${ARCH}" != "amd64" ]]; then
|
||||||
echo -e "${BGREEN}Register ${RED}/usr/bin/qemu-ARCH-static${BGREEN} as the handler for binaries in multiple platforms${NC}"
|
echo -e "${BGREEN}Register ${RED}/usr/bin/qemu-ARCH-static${BGREEN} as the handler for binaries in multiple platforms${NC}"
|
||||||
|
@ -102,7 +103,7 @@ docker run \
|
||||||
-v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \
|
-v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \
|
||||||
-v "${HOME}/.kube:${HOME}/.kube:ro" \
|
-v "${HOME}/.kube:${HOME}/.kube:ro" \
|
||||||
${MINIKUBE_VOLUME} \
|
${MINIKUBE_VOLUME} \
|
||||||
"${IMAGE}-${ARCH}:local" /nginx-ingress-controller \
|
"${IMAGE}:${TAG}" /nginx-ingress-controller \
|
||||||
--update-status=false \
|
--update-status=false \
|
||||||
--v=2 \
|
--v=2 \
|
||||||
--apiserver-host=http://0.0.0.0:8001 \
|
--apiserver-host=http://0.0.0.0:8001 \
|
||||||
|
|
|
@ -24,7 +24,6 @@ endif
|
||||||
|
|
||||||
ARCH ?= $(shell go env GOARCH)
|
ARCH ?= $(shell go env GOARCH)
|
||||||
GOARCH = ${ARCH}
|
GOARCH = ${ARCH}
|
||||||
DUMB_ARCH = ${ARCH}
|
|
||||||
|
|
||||||
BASEIMAGE?=alpine:3.9
|
BASEIMAGE?=alpine:3.9
|
||||||
|
|
||||||
|
|
|
@ -262,14 +262,14 @@ func TestConfigureDynamically(t *testing.T) {
|
||||||
func TestConfigureCertificates(t *testing.T) {
|
func TestConfigureCertificates(t *testing.T) {
|
||||||
listener, err := net.Listen("unix", nginx.StatusSocket)
|
listener, err := net.Listen("unix", nginx.StatusSocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("crating unix listener: %s", err)
|
t.Fatalf("crating unix listener: %s", err)
|
||||||
}
|
}
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
defer os.Remove(nginx.StatusSocket)
|
defer os.Remove(nginx.StatusSocket)
|
||||||
|
|
||||||
streamListener, err := net.Listen("unix", nginx.StreamSocket)
|
streamListener, err := net.Listen("unix", nginx.StreamSocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("crating unix listener: %s", err)
|
t.Fatalf("crating unix listener: %s", err)
|
||||||
}
|
}
|
||||||
defer streamListener.Close()
|
defer streamListener.Close()
|
||||||
defer os.Remove(nginx.StreamSocket)
|
defer os.Remove(nginx.StreamSocket)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
IMAGE=nginx-ingress-controller:e2e
|
.PHONY: all
|
||||||
|
|
||||||
.PHONY: all container getbins clean
|
|
||||||
|
|
||||||
all: container
|
all: container
|
||||||
|
|
||||||
|
.PHONY: container
|
||||||
container:
|
container:
|
||||||
make -C ../../ e2e-test-binary
|
make -C ../../ e2e-test-binary
|
||||||
|
|
||||||
|
@ -12,8 +10,9 @@ container:
|
||||||
cp -r ../../deploy/cloud-generic .
|
cp -r ../../deploy/cloud-generic .
|
||||||
cp -r ../../deploy/cluster-wide .
|
cp -r ../../deploy/cluster-wide .
|
||||||
|
|
||||||
docker build -t $(IMAGE) .
|
docker build -t nginx-ingress-controller:e2e .
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf _cache e2e.test kubectl cluster ginkgo
|
rm -rf _cache e2e.test kubectl cluster ginkgo
|
||||||
docker rmi -f $(IMAGE) || true
|
docker rmi -f nginx-ingress-controller:e2e || true
|
||||||
|
|
|
@ -56,6 +56,9 @@ echo "[dev-env] building container"
|
||||||
make -C ${DIR}/../../ build container
|
make -C ${DIR}/../../ build container
|
||||||
make -C ${DIR}/../../ e2e-test-image
|
make -C ${DIR}/../../ e2e-test-image
|
||||||
|
|
||||||
|
# Remove after https://github.com/kubernetes/ingress-nginx/pull/4271 is merged
|
||||||
|
docker tag ${REGISTRY}/nginx-ingress-controller-${ARCH}:${TAG} ${REGISTRY}/nginx-ingress-controller:${TAG}
|
||||||
|
|
||||||
echo "[dev-env] copying docker images to cluster..."
|
echo "[dev-env] copying docker images to cluster..."
|
||||||
kind load docker-image --name="${KIND_CLUSTER_NAME}" nginx-ingress-controller:e2e
|
kind load docker-image --name="${KIND_CLUSTER_NAME}" nginx-ingress-controller:e2e
|
||||||
kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/nginx-ingress-controller:${TAG}
|
kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/nginx-ingress-controller:${TAG}
|
||||||
|
|
Loading…
Reference in a new issue