-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy logs before Gardener deprovision
- Loading branch information
Showing
13 changed files
with
198 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Description: This script deletes the Gardener cluster | ||
# It requires the following env variables: | ||
# - CLUSTER_NAME - name of the cluster to be deleted | ||
# - GARDENER_KUBECONFIG - Gardener kubeconfig path | ||
# - GARDENER_PROJECT_NAME - name of the Gardener project | ||
|
||
set -eo pipefail | ||
script_dir="$(dirname "$(readlink -f "$0")")" | ||
|
||
function check_required_vars() { | ||
local requiredVarMissing=false | ||
for var in "$@"; do | ||
if [ -z "${!var}" ]; then | ||
>&2 echo "Environment variable ${var} is required but not set" | ||
requiredVarMissing=true | ||
fi | ||
done | ||
if [ "${requiredVarMissing}" = true ] ; then | ||
exit 2 | ||
fi | ||
} | ||
|
||
function check_required_files() { | ||
local requiredFileMissing=false | ||
for file in "$@"; do | ||
path=$(eval echo "\$$file") | ||
if [ ! -f "${path}" ]; then | ||
>&2 echo "File '${path}' required but not found" | ||
requiredFileMissing=true | ||
fi | ||
done | ||
if [ "${requiredFileMissing}" = true ] ; then | ||
exit 2 | ||
fi | ||
} | ||
|
||
requiredVars=( | ||
CLUSTER_NAME | ||
GARDENER_PROJECT_NAME | ||
) | ||
|
||
requiredFiles=( | ||
GARDENER_KUBECONFIG | ||
) | ||
|
||
check_required_vars "${requiredVars[@]}" | ||
check_required_files "${requiredFiles[@]}" | ||
|
||
echo "Deprovisioning cluster: ${CLUSTER_NAME}" | ||
|
||
kubectl annotate shoot "${CLUSTER_NAME}" confirmation.gardener.cloud/deletion=true \ | ||
--overwrite \ | ||
-n "garden-${GARDENER_PROJECT_NAME}" \ | ||
--kubeconfig "${GARDENER_KUBECONFIG}" | ||
|
||
kubectl delete shoot "${CLUSTER_NAME}" \ | ||
--wait="false" \ | ||
--kubeconfig "${GARDENER_KUBECONFIG}" \ | ||
-n "garden-${GARDENER_PROJECT_NAME}" |
Oops, something went wrong.