Skip to content

Commit

Permalink
Move cluster create/delete to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdharmon committed Mar 11, 2020
1 parent c588a3f commit 5e03763
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
VERSION?=$(shell git describe --tags)
IMAGE:=pod-reaper:$(VERSION)

CLUSTER_NAME=e2e

all: build

build:
Expand All @@ -18,9 +20,6 @@ test-unit:
./test/run-unit-tests.sh

test-e2e:
kind create cluster
docker pull kubernetes/pause
kind load docker-image kubernetes/pause
kind get kubeconfig > /tmp/admin.conf
./test/create-cluster.sh $(CLUSTER_NAME)
./test/run-e2e-tests.sh
kind delete cluster
./test/delete-cluster.sh $(CLUSTER_NAME)
16 changes: 16 additions & 0 deletions test/create-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
NAME=$1
KUBECONFIG=/tmp/admin.conf

kind get clusters | grep "${NAME}" > /dev/null
if [ $? -eq 1 ]; then
kind create cluster --name "${NAME}"
else
echo "Cluster \"${NAME}\" already exists."
fi

docker pull kubernetes/pause
kind load docker-image --name "${NAME}" kubernetes/pause
kind get kubeconfig --name "${NAME}" > ${KUBECONFIG}

echo "Output kubeconfig to ${KUBECONFIG}"
9 changes: 9 additions & 0 deletions test/delete-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
NAME=$1

kind get clusters | grep "${NAME}" > /dev/null
if [ $? -eq 0 ]; then
kind delete cluster --name "${NAME}"
else
echo "Cluster \"${NAME}\" does not exist."
fi

1 comment on commit 5e03763

@brianberzins
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still need to spend more time with this. The makefile doesn't work for me locally, but that's likely a result of my build environment. Almost everything info locally is just done in a docker container and as a result I almost never use makefiles. I'm still working my way through.

Please sign in to comment.