Migrate e2e cluster to kind
This commit is contained in:
parent
080bed8e88
commit
3339db2cb5
6 changed files with 70 additions and 63 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -45,3 +45,5 @@ gh-pages
|
||||||
/.env
|
/.env
|
||||||
/.gocache/
|
/.gocache/
|
||||||
/bin/
|
/bin/
|
||||||
|
|
||||||
|
test/e2e-image/wait-for-nginx\.sh
|
||||||
|
|
|
@ -44,10 +44,12 @@ jobs:
|
||||||
- stage: e2e
|
- stage: e2e
|
||||||
if: (branch = master AND env(COMPONENT) != "docs") OR (type = pull_request AND commit_message !~ /(skip-e2e)/)
|
if: (branch = master AND env(COMPONENT) != "docs") OR (type = pull_request AND commit_message !~ /(skip-e2e)/)
|
||||||
before_script:
|
before_script:
|
||||||
|
- sudo mkdir -p /home/travis/.kube/ && sudo chmod 777 /home/travis/.kube/
|
||||||
|
- curl -sSL -o kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.4/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
|
||||||
|
- curl -sSL -o kind https://github.com/kubernetes-sigs/kind/releases/download/0.2.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
|
||||||
- make e2e-test-image
|
- make e2e-test-image
|
||||||
- test/e2e/up.sh
|
|
||||||
script:
|
script:
|
||||||
- KUBECONFIG=$(cat /tmp/kubeconfig) make e2e-test
|
- test/e2e/run.sh
|
||||||
# split builds to avoid job timeouts
|
# split builds to avoid job timeouts
|
||||||
- stage: publish amd64
|
- stage: publish amd64
|
||||||
if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller"
|
if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller"
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -26,7 +26,7 @@ GOHOSTOS ?= $(shell go env GOHOSTOS)
|
||||||
# Allow limiting the scope of the e2e tests. By default run everything
|
# Allow limiting the scope of the e2e tests. By default run everything
|
||||||
FOCUS ?= .*
|
FOCUS ?= .*
|
||||||
# number of parallel test
|
# number of parallel test
|
||||||
E2E_NODES ?= 8
|
E2E_NODES ?= 10
|
||||||
# slow test only if takes > 50s
|
# slow test only if takes > 50s
|
||||||
SLOW_E2E_THRESHOLD ?= 50
|
SLOW_E2E_THRESHOLD ?= 50
|
||||||
|
|
||||||
|
@ -184,10 +184,10 @@ lua-test:
|
||||||
.PHONY: e2e-test
|
.PHONY: e2e-test
|
||||||
e2e-test:
|
e2e-test:
|
||||||
if [ "$(KUBECTL_CONTEXT)" != "minikube" ] && \
|
if [ "$(KUBECTL_CONTEXT)" != "minikube" ] && \
|
||||||
[ "$(KUBECTL_CONTEXT)" != "kind" ] && \
|
[ "$(KUBECTL_CONTEXT)" =~ .*kind* ] && \
|
||||||
[ "$(KUBECTL_CONTEXT)" != "dind" ] && \
|
[ "$(KUBECTL_CONTEXT)" != "dind" ] && \
|
||||||
[ "$(KUBECTL_CONTEXT)" != "docker-for-desktop" ]; then \
|
[ "$(KUBECTL_CONTEXT)" != "docker-for-desktop" ]; then \
|
||||||
echo "kubectl context is "$(KUBECTL_CONTEXT)", but must be one of [minikube, kind, dind, docker-for-deskop]"; \
|
echo "kubectl context is "$(KUBECTL_CONTEXT)", but must be one of [minikube, *kind*, dind, docker-for-deskop]"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
6
test/e2e/kind.yaml
Normal file
6
test/e2e/kind.yaml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
kind: Config
|
||||||
|
apiVersion: kind.sigs.k8s.io/v1alpha2
|
||||||
|
nodes:
|
||||||
|
- role: control-plane
|
||||||
|
- role: worker
|
||||||
|
replicas: 3
|
55
test/e2e/run.sh
Executable file
55
test/e2e/run.sh
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
export TAG=dev
|
||||||
|
export ARCH=amd64
|
||||||
|
export REGISTRY=${REGISTRY:-ingress-controller}
|
||||||
|
|
||||||
|
KIND_CLUSTER_NAME="ingress-nginx-dev"
|
||||||
|
|
||||||
|
kind --version || $(echo "Please install kind before running e2e tests";exit 1)
|
||||||
|
|
||||||
|
SKIP_CLUSTER_CREATION=${SKIP_CLUSTER_CREATION:-}
|
||||||
|
if [ -z "${SKIP_CLUSTER_CREATION}" ]; then
|
||||||
|
echo "[dev-env] creating Kubernetes cluster with kind"
|
||||||
|
kind create cluster --name ${KIND_CLUSTER_NAME} --config ${DIR}/kind.yaml
|
||||||
|
fi
|
||||||
|
|
||||||
|
export KUBECONFIG="$(kind get kubeconfig-path --name="${KIND_CLUSTER_NAME}")"
|
||||||
|
|
||||||
|
sleep 60
|
||||||
|
|
||||||
|
echo "Kubernetes cluster:"
|
||||||
|
kubectl get nodes -o wide
|
||||||
|
|
||||||
|
echo "[dev-env] installing kubectl"
|
||||||
|
kubectl version || $(echo "Please install kubectl before running e2e tests";exit 1)
|
||||||
|
|
||||||
|
kubectl config set-context kubernetes-admin@${KIND_CLUSTER_NAME}
|
||||||
|
|
||||||
|
echo "[dev-env] building container"
|
||||||
|
make -C ${DIR}/../../ build container
|
||||||
|
make -C ${DIR}/../../ e2e-test-image
|
||||||
|
|
||||||
|
echo "copying docker images to cluster..."
|
||||||
|
kind load docker-image --name="${KIND_CLUSTER_NAME}" ${REGISTRY}/nginx-ingress-controller:${TAG}
|
||||||
|
kind load docker-image --name="${KIND_CLUSTER_NAME}" nginx-ingress-controller:e2e
|
||||||
|
|
||||||
|
make -C ${DIR}/../../ e2e-test
|
|
@ -1,58 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
if test -e kubectl; then
|
|
||||||
echo "skipping download of kubectl"
|
|
||||||
else
|
|
||||||
echo "downloading kubectl..."
|
|
||||||
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.13.3/bin/linux/amd64/kubectl \
|
|
||||||
&& chmod +x kubectl && sudo mv kubectl /usr/local/bin/
|
|
||||||
fi
|
|
||||||
|
|
||||||
export KUBECONFIG="$(mktemp)"
|
|
||||||
echo -n ${KUBECONFIG} > /tmp/kubeconfig
|
|
||||||
|
|
||||||
echo "starting Kubernetes cluster..."
|
|
||||||
K8S_VERSION=v1.11
|
|
||||||
KDC_SHA=e505612125948bab5a415ec3e5c1f9f26324488f28286e005fd1f3a0a6292c49
|
|
||||||
curl -Lo $DIR/dind-cluster-$K8S_VERSION.sh https://github.com/kubernetes-sigs/kubeadm-dind-cluster/releases/download/v0.1.0/dind-cluster-$K8S_VERSION.sh && \
|
|
||||||
chmod +x $DIR/dind-cluster-$K8S_VERSION.sh
|
|
||||||
|
|
||||||
echo "$KDC_SHA $DIR/dind-cluster-$K8S_VERSION.sh" | sha256sum -c - || exit 10
|
|
||||||
$DIR/dind-cluster-$K8S_VERSION.sh up
|
|
||||||
|
|
||||||
kubectl config use-context dind
|
|
||||||
|
|
||||||
echo "Kubernetes cluster:"
|
|
||||||
kubectl get nodes -o wide
|
|
||||||
|
|
||||||
export TAG=dev
|
|
||||||
export ARCH=amd64
|
|
||||||
export REGISTRY=${REGISTRY:-ingress-controller}
|
|
||||||
|
|
||||||
echo "building container..."
|
|
||||||
make -C ${DIR}/../../ build container
|
|
||||||
|
|
||||||
echo "copying docker image to cluster..."
|
|
||||||
DEV_IMAGE=${REGISTRY}/nginx-ingress-controller:${TAG}
|
|
||||||
${DIR}/dind-cluster-v1.11.sh copy-image ${DEV_IMAGE}
|
|
||||||
|
|
||||||
echo "copying e2e docker image to cluster..."
|
|
||||||
${DIR}/dind-cluster-v1.11.sh copy-image nginx-ingress-controller:e2e
|
|
Loading…
Reference in a new issue