forked from lifechurch/k8s-deploy-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
destroy
executable file
·25 lines (20 loc) · 1.12 KB
/
destroy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
export DEPLOY_ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$DEPLOY_ROOT_DIR/src/common.bash"
if [ "x$1" != "x" ]; then
echo "Removing all deployment objects for $1"
kubectl delete deploy,pod,rs,svc,ing,ds -l "$1" -n "$KUBE_NAMESPACE"
else
echo "Removing all deployment objects"
kubectl delete deploy,pod,rs,svc,ing,ds -l "app=$CI_ENVIRONMENT_SLUG" -n "$KUBE_NAMESPACE"
echo "We are deleting on the environment=$CI_ENVIRONMENT_SLUG label for review apps with workers. You should be able to ignore errors below."
kubectl delete deploy,pod,rs,svc,ing,ds -l "environment=$CI_ENVIRONMENT_SLUG" -n "$KUBE_NAMESPACE" || true
fi
echo "Removing auto-generated secrets..."
kubectl delete secret $KUBE_NAMESPACE-secrets-$STAGE -n "$KUBE_NAMESPACE" || true