Skip to content

Commit

Permalink
Remove all pods before cleanup to release volumes mounted with rshare…
Browse files Browse the repository at this point in the history
…d propagation

Fixes #96
  • Loading branch information
mcanevet committed Oct 10, 2020
1 parent dd0c0c6 commit e0c470c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ jobs:
- uses: actions/checkout@v2
- run: make debug
- run: make
- run: make clean
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ clean: get-base-domain
--entrypoint "" \
--workdir /workdir \
hashicorp/terraform:$(TERRAFORM_VERSION) /workdir/scripts/destroy-vault.sh
docker run --rm \
--user $(UID_NUMBER):$(GID_NUMBER) \
-v $$PWD:/workdir \
-v $$PWD/$(ARTIFACTS_DIR)/kubeconfig.yaml:/tmp/.kube/config \
--network k3s-$(CLUSTER_NAME) \
--env HOME=/tmp \
--env KUBECTL_COMMAND=apply \
--env ARGOCD_OPTS="--plaintext --port-forward --port-forward-namespace argocd" \
--env ARTIFACTS_DIR=$(ARTIFACTS_DIR) \
--entrypoint "" \
--workdir /workdir \
argoproj/argocd:v$(ARGOCD_VERSION) /workdir/scripts/pre-clean.sh
touch $$HOME/.terraformrc
docker run --rm \
--group-add $(DOCKER_GID_NUMBER) \
Expand Down
21 changes: 21 additions & 0 deletions scripts/pre-clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh -xe

# Remove all Applications to prevent ArgoCD to reconcile
kubectl -n argocd delete application --all

# Remove all Operators to ensure that it does not redeploy stuffs
kubectl -n cluster-operators delete deployments --all

# Remove all pods to release volume mounted with rshared propagation
kubectl delete daemonsets --all --all-namespaces
kubectl delete statefulsets --all --all-namespaces
kubectl delete deployments --all --all-namespaces
kubectl delete cronjobs --all --all-namespaces
kubectl delete jobs --all --all-namespaces
kubectl delete horizontalpodautoscaler --all --all-namespaces
kubectl delete service --all --all-namespaces

while test "$(kubectl get pods --all-namespaces | wc -l)" -ne 0; do
echo Waiting for destruction of all pods
sleep 3
done

0 comments on commit e0c470c

Please sign in to comment.