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/
|
||||
|
||||
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)
|
||||
GOARCH = ${ARCH}
|
||||
DUMB_ARCH = ${ARCH}
|
||||
|
||||
|
||||
GOBUILD_FLAGS := -v
|
||||
|
||||
|
@ -56,13 +56,9 @@ BUSTED_ARGS =-v --pattern=_test
|
|||
|
||||
GOOS = linux
|
||||
|
||||
IMGNAME = nginx-ingress-controller
|
||||
IMAGE = $(REGISTRY)/$(IMGNAME)
|
||||
|
||||
MULTI_ARCH_IMG = ${IMAGE}-${ARCH}
|
||||
MULTI_ARCH_IMAGE = $(REGISTRY)/nginx-ingress-controller-${ARCH}
|
||||
|
||||
export ARCH
|
||||
export DUMB_ARCH
|
||||
export TAG
|
||||
export PKG
|
||||
export GOARCH
|
||||
|
@ -116,7 +112,6 @@ container: clean-container .container-$(ARCH)
|
|||
cp -RP ./* $(TEMP_DIR)
|
||||
$(SED_I) "s|BASEIMAGE|$(BASEIMAGE)|g" $(DOCKERFILE)
|
||||
$(SED_I) "s|QEMUARCH|$(QEMUARCH)|g" $(DOCKERFILE)
|
||||
$(SED_I) "s|DUMB_ARCH|$(DUMB_ARCH)|g" $(DOCKERFILE)
|
||||
|
||||
ifeq ($(ARCH),amd64)
|
||||
# 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)
|
||||
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
|
||||
clean-container:
|
||||
@$(DOCKER) rmi -f $(MULTI_ARCH_IMG):$(TAG) || true
|
||||
@$(DOCKER) rmi -f $(MULTI_ARCH_IMAGE):$(TAG) || true
|
||||
|
||||
.PHONY: register-qemu
|
||||
register-qemu:
|
||||
|
@ -148,10 +140,7 @@ push: .push-$(ARCH)
|
|||
|
||||
.PHONY: .push-$(ARCH)
|
||||
.push-$(ARCH):
|
||||
$(DOCKER) push $(MULTI_ARCH_IMG):$(TAG)
|
||||
ifeq ($(ARCH), amd64)
|
||||
$(DOCKER) push $(IMAGE):$(TAG)
|
||||
endif
|
||||
$(DOCKER) push $(MULTI_ARCH_IMAGE):$(TAG)
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
|
|
|
@ -22,10 +22,20 @@ set -o errexit
|
|||
set -o nounset
|
||||
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
|
||||
|
||||
DOCKER_OPTS=${DOCKER_OPTS:-}
|
||||
|
||||
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd -P)
|
||||
|
||||
FLAGS=$@
|
||||
|
||||
PKG=k8s.io/ingress-nginx
|
||||
|
@ -34,20 +44,21 @@ ARCH=$(go env GOARCH)
|
|||
MINIKUBE_PATH=${HOME}/.minikube
|
||||
MINIKUBE_VOLUME="-v ${MINIKUBE_PATH}:${MINIKUBE_PATH}"
|
||||
if [ ! -d "${MINIKUBE_PATH}" ]; then
|
||||
echo "Minikube directory not found! Volume will be excluded from docker build."
|
||||
MINIKUBE_VOLUME=""
|
||||
echo "Minikube directory not found! Volume will be excluded from docker build."
|
||||
MINIKUBE_VOLUME=""
|
||||
fi
|
||||
|
||||
docker run \
|
||||
--tty \
|
||||
--rm \
|
||||
${DOCKER_OPTS} \
|
||||
-v "${HOME}/.kube:${HOME}/.kube" \
|
||||
-v "${PWD}:/go/src/${PKG}" \
|
||||
-v "${PWD}/.gocache:${HOME}/.cache/go-build" \
|
||||
-v "${PWD}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
|
||||
-v "/var/run/docker.sock:/var/run/docker.sock" \
|
||||
${MINIKUBE_VOLUME} \
|
||||
-w "/go/src/${PKG}" \
|
||||
-u $(id -u ${USER}):$(id -g ${USER}) \
|
||||
docker run \
|
||||
--tty \
|
||||
--rm \
|
||||
${DOCKER_OPTS} \
|
||||
-e GOCACHE="/go/src/${PKG}/.cache" \
|
||||
-v "${HOME}/.kube:${HOME}/.kube" \
|
||||
-v "${KUBE_ROOT}:/go/src/${PKG}" \
|
||||
-v "${KUBE_ROOT}/bin/${ARCH}:/go/bin/linux_${ARCH}" \
|
||||
-v "/var/run/docker.sock:/var/run/docker.sock" \
|
||||
-v "${SSL_VOLUME}:/etc/ingress-controller/ssl/" \
|
||||
${MINIKUBE_VOLUME} \
|
||||
-w "/go/src/${PKG}" \
|
||||
-u $(id -u ${USER}):$(id -g ${USER}) \
|
||||
${E2E_IMAGE} /bin/bash -c "${FLAGS}"
|
||||
|
|
|
@ -62,6 +62,7 @@ POD_NAMESPACE="invalid-namespace"
|
|||
POD_NAME="invalid-namespace"
|
||||
|
||||
export TAG=local
|
||||
export IMAGE
|
||||
|
||||
if [[ "${ARCH}" != "amd64" ]]; then
|
||||
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 "${HOME}/.kube:${HOME}/.kube:ro" \
|
||||
${MINIKUBE_VOLUME} \
|
||||
"${IMAGE}-${ARCH}:local" /nginx-ingress-controller \
|
||||
"${IMAGE}:${TAG}" /nginx-ingress-controller \
|
||||
--update-status=false \
|
||||
--v=2 \
|
||||
--apiserver-host=http://0.0.0.0:8001 \
|
||||
|
|
|
@ -24,7 +24,6 @@ endif
|
|||
|
||||
ARCH ?= $(shell go env GOARCH)
|
||||
GOARCH = ${ARCH}
|
||||
DUMB_ARCH = ${ARCH}
|
||||
|
||||
BASEIMAGE?=alpine:3.9
|
||||
|
||||
|
|
|
@ -262,14 +262,14 @@ func TestConfigureDynamically(t *testing.T) {
|
|||
func TestConfigureCertificates(t *testing.T) {
|
||||
listener, err := net.Listen("unix", nginx.StatusSocket)
|
||||
if err != nil {
|
||||
t.Errorf("crating unix listener: %s", err)
|
||||
t.Fatalf("crating unix listener: %s", err)
|
||||
}
|
||||
defer listener.Close()
|
||||
defer os.Remove(nginx.StatusSocket)
|
||||
|
||||
streamListener, err := net.Listen("unix", nginx.StreamSocket)
|
||||
if err != nil {
|
||||
t.Errorf("crating unix listener: %s", err)
|
||||
t.Fatalf("crating unix listener: %s", err)
|
||||
}
|
||||
defer streamListener.Close()
|
||||
defer os.Remove(nginx.StreamSocket)
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
IMAGE=nginx-ingress-controller:e2e
|
||||
|
||||
.PHONY: all container getbins clean
|
||||
|
||||
.PHONY: all
|
||||
all: container
|
||||
|
||||
.PHONY: container
|
||||
container:
|
||||
make -C ../../ e2e-test-binary
|
||||
|
||||
|
@ -12,8 +10,9 @@ container:
|
|||
cp -r ../../deploy/cloud-generic .
|
||||
cp -r ../../deploy/cluster-wide .
|
||||
|
||||
docker build -t $(IMAGE) .
|
||||
docker build -t nginx-ingress-controller:e2e .
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
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}/../../ 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..."
|
||||
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}
|
||||
|
|
Loading…
Reference in a new issue