Skip to content

Commit

Permalink
Migrate e2e cluster to kind
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Mar 20, 2019
1 parent 080bed8 commit 3339db2
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 63 deletions.
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

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.

0 comments on commit 3339db2

Please sign in to comment.