Skip to content

Commit

Permalink
hack: Add clean_crs.sh to help cleaning CRs for dev/test
Browse files Browse the repository at this point in the history
Remember to stop the managers before running the script if intent for
testing, otherwise manager will clean up the volumes.

Use `./hack/clean_crs.sh v062` to clean all the custom resources of
`longhorn.rancher.io/v1alpha1`

Use `./hack/clean_crs.sh v070` to clean all the custom resources of
`longhorn.io/v1beta1`

Signed-off-by: Sheng Yang <sheng.yang@rancher.com>
  • Loading branch information
yasker committed Nov 7, 2019
1 parent af6591c commit 4373b3a
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions hack/cleancrs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

set -x

namespace=longhorn-system

clean_crs() {
crd=$1
kubectl -n $namespace get $crd --no-headers|cut -f1 -d" "| xargs kubectl -n $namespace patch $crd --type='merge' -p '{"metadata":{"finalizers": null}}'
kubectl -n $namespace delete $crd --all
}

crd_list_v070=(
volumes.longhorn.io
replicas.longhorn.io
engines.longhorn.io
instancemanagers.longhorn.io
engineimages.longhorn.io
nodes.longhorn.io
settings.longhorn.io
)

crd_list_v062=(
volumes.longhorn.rancher.io
replicas.longhorn.rancher.io
engines.longhorn.rancher.io
instancemanagers.longhorn.rancher.io
engineimages.longhorn.rancher.io
nodes.longhorn.rancher.io
settings.longhorn.rancher.io
)

version=$1
case $version in
"v062")
list=("${crd_list_v062[@]}")
;;
"v070")
list=("${crd_list_v070[@]}")
;;
*)
echo "invalid version to clean up"
exit 1
esac

for crd in "${list[@]}"
do
clean_crs $crd
done

#kubectl -n longhorn-system get instancemanagers.longhorn.rancher.io --no-headers|cut -f1 -d" "| xargs kubectl -n longhorn-system patch instancemanagers.longhorn.rancher.io --type='merge' -p '{"metadata":{"finalizers": null}}'

0 comments on commit 4373b3a

Please sign in to comment.