Skip to content

Commit 5e03763

Browse files
committed
Move cluster create/delete to scripts
1 parent c588a3f commit 5e03763

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
VERSION?=$(shell git describe --tags)
44
IMAGE:=pod-reaper:$(VERSION)
55

6+
CLUSTER_NAME=e2e
7+
68
all: build
79

810
build:
@@ -18,9 +20,6 @@ test-unit:
1820
./test/run-unit-tests.sh
1921

2022
test-e2e:
21-
kind create cluster
22-
docker pull kubernetes/pause
23-
kind load docker-image kubernetes/pause
24-
kind get kubeconfig > /tmp/admin.conf
23+
./test/create-cluster.sh $(CLUSTER_NAME)
2524
./test/run-e2e-tests.sh
26-
kind delete cluster
25+
./test/delete-cluster.sh $(CLUSTER_NAME)

test/create-cluster.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
NAME=$1
3+
KUBECONFIG=/tmp/admin.conf
4+
5+
kind get clusters | grep "${NAME}" > /dev/null
6+
if [ $? -eq 1 ]; then
7+
kind create cluster --name "${NAME}"
8+
else
9+
echo "Cluster \"${NAME}\" already exists."
10+
fi
11+
12+
docker pull kubernetes/pause
13+
kind load docker-image --name "${NAME}" kubernetes/pause
14+
kind get kubeconfig --name "${NAME}" > ${KUBECONFIG}
15+
16+
echo "Output kubeconfig to ${KUBECONFIG}"

test/delete-cluster.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
NAME=$1
3+
4+
kind get clusters | grep "${NAME}" > /dev/null
5+
if [ $? -eq 0 ]; then
6+
kind delete cluster --name "${NAME}"
7+
else
8+
echo "Cluster \"${NAME}\" does not exist."
9+
fi

0 commit comments

Comments
 (0)