Skip to content

Commit

Permalink
Merge pull request spidernet-io#3706 from ty-dc/fix/3696
Browse files Browse the repository at this point in the history
Optimize clean scripts
  • Loading branch information
weizhoublue committed Jul 11, 2024
2 parents 9331847 + 80c61bb commit 0f4724d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
17 changes: 13 additions & 4 deletions docs/usage/install/uninstall-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

`<spiderpool-name>` 替换为要卸载的 Spiderpool 的名称,将 `<spiderpool-namespace>` 替换为 Spiderpool 所在的命名空间。

### v0.10.0 以上版本
### v1.0.0 以上版本

v0.10.0 之后引入了自动清理 Spiderpool 资源的功能,它通过 `spiderpoolController.cleanup.enabled` 配置项来启用,该值默认为 `true`,您可以通过如下方式验证与 Spiderpool 相关的资源数量是否自动被清理。
v1.0.0 之后引入了自动清理 Spiderpool 资源的功能,它通过 `spiderpoolController.cleanup.enabled` 配置项来启用,该值默认为 `true`,您可以通过如下方式验证与 Spiderpool 相关的资源数量是否自动被清理。

```bash
kubectl get spidersubnets.spiderpool.spidernet.io -o name | wc -l
Expand All @@ -39,9 +39,18 @@ kubectl get spiderendpoints.spiderpool.spidernet.io -o name | wc -l
kubectl get spidercoordinators.spiderpool.spidernet.io -o name | wc -l
```

### v0.10.0 以下版本
### v1.0.0 以下版本

在低于 v0.10.0 的版本中,由于 Spiderpool 的某些 CR 资源中存在 [finalizers](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/) ,导致 `helm uninstall` 命令无法清理干净,您需要手动清理。可获取如下清理脚本来完成清理,以确保下次部署 Spiderpool 时不会出现意外错误。
在低于 v1.0.0 的版本中,由于 Spiderpool 的某些 CR 资源中存在 [finalizers](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/) ,导致 `helm uninstall` 命令无法清理干净,您需要手动清理。可获取如下清理脚本来完成清理,以确保下次部署 Spiderpool 时不会出现意外错误。

```bash
wget https://raw.githubusercontent.com/spidernet-io/spiderpool/main/tools/scripts/cleanCRD.sh
chmod +x cleanCRD.sh && ./cleanCRD.sh
```

## FAQ

删除 Spiderpool 未使用 `helm uninstall` 方式,而是通过 `kubectl delete <spiderpool 部署的 namespace>`,导致出现资源卸载残留,从而影响新的安装。您需要手动清理。可获取如下清理脚本来完成清理,以确保下次部署 Spiderpool 时不会出现意外错误。

```bash
wget https://raw.githubusercontent.com/spidernet-io/spiderpool/main/tools/scripts/cleanCRD.sh
Expand Down
17 changes: 13 additions & 4 deletions docs/usage/install/uninstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Understand the running application and understand the impact that uninstalling S

Replace `<spiderpool-name>` with the name of the Spiderpool you want to uninstall and `<spiderpool-namespace>` with the namespace of the Spiderpool.

### Above v0.10.0
### Above v1.0.0

The function of automatically cleaning Spiderpool resources was introduced after v0.10.0. It is enabled through the `spiderpoolController.cleanup.enabled` configuration item. The value defaults to `true`. You can verify whether the number of resources related to Spiderpool is automatically cleared as follows.
The function of automatically cleaning Spiderpool resources was introduced after v1.0.0. It is enabled through the `spiderpoolController.cleanup.enabled` configuration item. The value defaults to `true`. You can verify whether the number of resources related to Spiderpool is automatically cleared as follows.

```bash
kubectl get spidersubnets.spiderpool.spidernet.io -o name | wc -l
Expand All @@ -39,9 +39,18 @@ kubectl get spiderendpoints.spiderpool.spidernet.io -o name | wc -l
kubectl get spidercoordinators.spiderpool.spidernet.io -o name | wc -l
```

### Below v0.10.0
### Below v1.0.0

In versions lower than v0.10.0, Some CR resources having [finalizers](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/) prevents complete cleanup via `helm uninstall`. You can download the cleaning script below to perform the necessary cleanup and avoid any unexpected errors during future deployments of Spiderpool.
In versions lower than v1.0.0, Some CR resources having [finalizers](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/) prevents complete cleanup via `helm uninstall`. You can download the cleaning script below to perform the necessary cleanup and avoid any unexpected errors during future deployments of Spiderpool.

```bash
wget https://raw.githubusercontent.com/spidernet-io/spiderpool/main/tools/scripts/cleanCRD.sh
chmod +x cleanCRD.sh && ./cleanCRD.sh
```

## FAQ

Spiderpool was not deleted using the `helm uninstall` method, but through `kubectl delete <spiderpool deployed namespace>`, which resulted in resource uninstallation residues, thus affecting the new installation. You need to clean it up manually. You can get the following cleanup script to complete the cleanup to ensure that there will be no unexpected errors when you deploy Spiderpool next time.

```bash
wget https://raw.githubusercontent.com/spidernet-io/spiderpool/main/tools/scripts/cleanCRD.sh
Expand Down
4 changes: 4 additions & 0 deletions tools/scripts/cleanCRD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# Copyright 2022 Authors of spidernet-io
# SPDX-License-Identifier: Apache-2.0

kubectl get MutatingWebhookConfiguration | sed '1 d' | awk '{print $1}' | grep spiderpool-controller | xargs -n 1 -i kubectl delete MutatingWebhookConfiguration {}

kubectl get ValidatingWebhookConfiguration | sed '1 d' | awk '{print $1}' | grep spiderpool-controller | xargs -n 1 -i kubectl delete ValidatingWebhookConfiguration {}

kubectl get spiderippools | sed '1 d' | awk '{print $1}' | xargs -n 1 -i kubectl patch spiderippools {} --patch '{"metadata": {"finalizers": null}}' --type=merge

kubectl get spidersubnets | sed '1 d' | awk '{print $1}' | xargs -n 1 -i kubectl patch spidersubnets {} --patch '{"metadata": {"finalizers": null}}' --type=merge
Expand Down

0 comments on commit 0f4724d

Please sign in to comment.