Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate e2e cluster to kind #3806

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ gh-pages
/.env
/.gocache/
/bin/

test/e2e-image/wait-for-nginx\.sh
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ jobs:
- stage: e2e
if: (branch = master AND env(COMPONENT) != "docs") OR (type = pull_request AND commit_message !~ /(skip-e2e)/)
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
- test/e2e/up.sh
script:
- KUBECONFIG=$(cat /tmp/kubeconfig) make e2e-test
- test/e2e/run.sh
# split builds to avoid job timeouts
- stage: publish amd64
if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "ingress-controller"
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GOHOSTOS ?= $(shell go env GOHOSTOS)
# Allow limiting the scope of the e2e tests. By default run everything
FOCUS ?= .*
# number of parallel test
E2E_NODES ?= 8
E2E_NODES ?= 10
# slow test only if takes > 50s
SLOW_E2E_THRESHOLD ?= 50

Expand Down Expand Up @@ -184,10 +184,10 @@ lua-test:
.PHONY: e2e-test
e2e-test:
if [ "$(KUBECTL_CONTEXT)" != "minikube" ] && \
[ "$(KUBECTL_CONTEXT)" != "kind" ] && \
[ "$(KUBECTL_CONTEXT)" =~ .*kind* ] && \
[ "$(KUBECTL_CONTEXT)" != "dind" ] && \
[ "$(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; \
fi

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Config
apiVersion: kind.sigs.k8s.io/v1alpha2
nodes:
- role: control-plane
- role: worker
replicas: 3
55 changes: 55 additions & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this waiting for cluster creation? If so is it not better to do it ater line 32 inside the if block?


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
58 changes: 0 additions & 58 deletions test/e2e/up.sh

This file was deleted.