linkerd2/bin/test-cleanup

31 lines
866 B
Bash
Executable File

#!/bin/bash
set -eu
linkerd_namespace=${1:-l5d-integration}
if [ -z "$linkerd_namespace" ]; then
echo "usage: $(basename "$0") <namespace>" >&2
exit 64
fi
echo "cleaning up namespace [${linkerd_namespace}] and associated test namespaces"
if ! namespaces=$(kubectl get ns -oname | grep -E "/$linkerd_namespace(-|$)"); then
echo "no namespaces found for [$linkerd_namespace]" >&2
else
kubectl delete $namespaces
fi
if ! clusterrolebindings=$(kubectl get clusterrolebindings -oname | grep -E "/linkerd-$linkerd_namespace(-|$)"); then
echo "no clusterrolebindings found for [$linkerd_namespace]" >&2
else
kubectl delete $clusterrolebindings
fi
if ! clusterroles=$(kubectl get clusterroles -oname | grep -E "/linkerd-$linkerd_namespace(-|$)"); then
echo "no clusterroles found for [$linkerd_namespace]" >&2
else
kubectl delete $clusterroles
fi