-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migration: Delete namespaces obsolete since v0.20
Fixes #1585 Rollback not implemented because the namespaces have been obsolete so long, plus this wouldn't restore any resources in the deleted namespaces anyway, so restoring them on their own seems of little value.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
ROOT="$(readlink -f "$(dirname "${0}")/../../../")" | ||
|
||
# shellcheck source=scripts/migration/lib.sh | ||
source "${ROOT}/scripts/migration/lib.sh" | ||
|
||
run() { | ||
case "${1:-}" in | ||
execute) | ||
for NS in elastic-system influxdb-prometheus; do | ||
if kubectl_do sc get namespace $NS >/dev/null 2>/dev/null; then | ||
log_info " - deleting unused namespace $NS in sc" | ||
kubectl_do sc delete namespace $NS | ||
else | ||
log_info " - skip deleting not present namespace $NS in sc" | ||
fi | ||
done | ||
;; | ||
rollback) | ||
log_warn " - restoration of unused namespaces not implemented" | ||
;; | ||
*) | ||
log_fatal "usage: \"${0}\" <execute|rollback>" | ||
;; | ||
esac | ||
} | ||
|
||
run "${@}" |
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,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
HERE="$(dirname "$(readlink -f "${0}")")" | ||
ROOT="$(readlink -f "${HERE}/../../../")" | ||
|
||
# shellcheck source=scripts/migration/lib.sh | ||
source "${ROOT}/scripts/migration/lib.sh" | ||
|
||
for NS in elastic-system influxdb-prometheus; do | ||
log_info "checking for resources in namespace $NS" | ||
NS_RESOURCES="$(kubectl_do sc get all -n $NS 2>&1)" | ||
if [[ "$NS_RESOURCES" == "No resources found in $NS namespace." ]]; then | ||
log_info "$NS_RESOURCES - safe to delete" | ||
else | ||
log_warn "Resources found in namespace $NS, please verify that these are okay to delete before proceeding to apply" | ||
echo "$NS_RESOURCES" | ||
fi | ||
done |