Skip to content

Commit

Permalink
Makefile: Add kind-down target for deleting dev kind cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
  • Loading branch information
lambdanis committed Jul 16, 2024
1 parent 62e394e commit 7f4e341
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ endif
.PHONY: kind-setup
kind-setup: kind kind-install-tetragon ## Create a kind cluster and install local version of Tetragon.

.PHONY: kind-down
kind-down: ## Delete a kind cluster for Tetragon development.
./contrib/kind/delete-kind-cluster.sh

##@ Chores and generated files

.PHONY: codegen protogen
Expand Down
2 changes: 1 addition & 1 deletion contrib/kind/bootstrap-kind-cluster.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/usr/bin/env bash

error() {
echo "$@" 1>&2
Expand Down
40 changes: 40 additions & 0 deletions contrib/kind/delete-kind-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

error() {
echo "$@" 1>&2
exit 1
}

set -eu

PROJECT_ROOT="$(git rev-parse --show-toplevel)"
cd "$PROJECT_ROOT"
source contrib/kind/conf

if ! command -v kind &>/dev/null; then
error "kind is not in \$PATH! Bailing out!"
fi

usage() {
echo "usage: delete-kind-cluster.sh [OPTIONS]" 1>&2
echo "OPTIONS:" 1>&2
echo " --cluster override cluster name" 1>&2
}

while [ $# -ge 1 ]; do
if [ "$1" == "--cluster" ]; then
CLUSTER_NAME="$2"
shift 2
else
usage
exit 1
fi
done


if ! kind get clusters | grep "$CLUSTER_NAME" &>/dev/null; then
echo "Cluster $CLUSTER_NAME doesn't exist. Exiting." 1>&2
exit 0
else
kind delete cluster --name "$CLUSTER_NAME"
fi

0 comments on commit 7f4e341

Please sign in to comment.