mirror of https://github.com/linkerd/linkerd2.git
38 lines
1.5 KiB
Bash
Executable File
38 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
linkerd_namespace=${1:-l5d-integration}
|
|
k8s_context=${2:-""}
|
|
|
|
if [ -z "$linkerd_namespace" ]; then
|
|
echo "usage: $(basename "$0") <namespace> [k8s-context]">&2
|
|
exit 64
|
|
fi
|
|
|
|
echo "cleaning up namespace [${linkerd_namespace}] in k8s-context [${k8s_context}] and associated test namespaces"
|
|
|
|
if ! namespaces=$(kubectl --context=$k8s_context get ns -oname | grep -E "/$linkerd_namespace(-|$)"); then
|
|
echo "no namespaces found for [$linkerd_namespace]" >&2
|
|
fi
|
|
|
|
if ! clusterrolebindings=$(kubectl --context=$k8s_context get clusterrolebindings -oname | grep -E "/linkerd-$linkerd_namespace(-|$)"); then
|
|
echo "no clusterrolebindings found for [$linkerd_namespace]" >&2
|
|
fi
|
|
|
|
if ! clusterroles=$(kubectl --context=$k8s_context get clusterroles -oname | grep -E "/linkerd-$linkerd_namespace(-|$)"); then
|
|
echo "no clusterroles found for [$linkerd_namespace]" >&2
|
|
fi
|
|
|
|
if ! webhookconfigs=$(kubectl --context=$k8s_context get mutatingwebhookconfigurations -oname | grep -E "/linkerd(-|$)"); then
|
|
echo "no mutatingwebhookconfigurations found" >&2
|
|
fi
|
|
|
|
if ! validatingconfigs=$(kubectl --context=$k8s_context get validatingwebhookconfigurations -oname | grep -E "/linkerd(-|$)"); then
|
|
echo "no validatingwebhookconfigurations found" >&2
|
|
fi
|
|
|
|
if [[ $namespaces || $clusterrolebindings || $clusterroles || $webhookconfigs || $validatingconfigs ]]; then
|
|
kubectl --context=$k8s_context delete --wait=false $namespaces $clusterrolebindings $clusterroles $webhookconfigs $validatingconfigs
|
|
fi
|