Skip to content

Commit

Permalink
Dev remove fleet script and finalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
manno committed Jul 10, 2024
1 parent b533491 commit a8548f6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dev/remove-fleet
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ ctx=$(kubectl config current-context)

kubectl config use-context "$upstream_ctx"

# Remove controllers
helm uninstall -n cattle-fleet-system fleet

# Remove finalizers, this will prevent deletion of namespace fleet-local from hanging
for res in gitrepos.fleet.cattle.io bundledeployments.fleet.cattle.io bundles.fleet.cattle.io; do
kubectl get "$res" -A --no-headers | while read ns name _; do kubectl patch "$res" -n "$ns" "$name" -p '{"metadata":{"finalizers":[]}}' --type=merge; done
done

helm uninstall -n cattle-fleet-system fleet-crd

# make sure crds are removed
kubectl delete crd gitrepos.fleet.cattle.io bundledeployments.fleet.cattle.io bundles.fleet.cattle.io

kubectl delete ns cattle-fleet-system --now
kubectl delete ns cattle-fleet-clusters-system --now

# This will prevent deletion of namespace fleet-local from hanging
bd_ns=$(kubectl get ns -l fleet.cattle.io/managed=true --no-headers -o=jsonpath={.items[0].metadata.name})
kubectl patch bundledeployment fleet-agent-local -n $bd_ns -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch bundle fleet-agent-local -n fleet-local -p '{"metadata":{"finalizers":[]}}' --type=merge

kubectl delete ns fleet-local --now
kubectl delete ns -l "fleet.cattle.io/managed=true"

Expand All @@ -31,4 +36,3 @@ helm uninstall -n cattle-fleet-system fleet-agent
kubectl delete ns cattle-fleet-system --now

kubectl config use-context "$ctx"

0 comments on commit a8548f6

Please sign in to comment.