Skip to content

Commit

Permalink
Merge pull request spidernet-io#3715 from ty-dc/release-v0.9
Browse files Browse the repository at this point in the history
[cherry-pick] optimize clean scripts
  • Loading branch information
weizhoublue authored Jul 18, 2024
2 parents 2f9117e + 8e13725 commit f969112
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ nav:
- VWware vSphere: usage/install/cloud/get-started-vmware.md
- OpenStack: usage/install/cloud/get-started-openstack.md
- Upgrading: usage/install/upgrade.md
- Uninstalling: usage/install/uninstall.md
- System requirements: usage/install/system-requirements.md
- Concepts:
- Architecture: concepts/arch.md
Expand Down
58 changes: 58 additions & 0 deletions docs/usage/install/uninstall-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 卸载指南

[**English**](./uninstall.md) | **简体中文**

本卸载指南适用于在 Kubernetes 上运行的 Spiderpool。如果您有任何疑问,请随时通过 [Spiderpool Community](../../README-zh_CN.md#_6) 联系我们。

## 注意事项

- 在执行卸载之前,请阅读完整的卸载指南以了解所有必要的步骤。

## 卸载

了解正在运行应用,理解卸载 Spiderpool 可能对其他相关组件(如中间件) 产生的影响,请确保完全了解风险后,才开始执行卸载步骤。

1. 通过 `helm ls` 查询集群所安装的 Spiderpool

```bash
helm ls -A | grep -i spiderpool
```

2. 通过 `helm uninstall` 卸载 Spiderpool

```bash
helm uninstall <spiderpool-name> --namespace <spiderpool-namespace>
```

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

### v1.0.0 以上版本

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

```bash
kubectl get spidersubnets.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderips.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderippools.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderreservedips.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderendpoints.spiderpool.spidernet.io -o name | wc -l
kubectl get spidercoordinators.spiderpool.spidernet.io -o name | wc -l
```

### v1.0.0 以下版本

在低于 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
chmod +x cleanCRD.sh && ./cleanCRD.sh
```
58 changes: 58 additions & 0 deletions docs/usage/install/uninstall.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Uninstall Guide

**English** | [**简体中文**](./uninstall-zh_CN.md)

This uninstall guide is intended for Spiderpool running on Kubernetes. If you have questions, feel free to ping us on [Spiderpool Community](../../README.md#community).

## Warning

- Read the full uninstall guide to understand all the necessary steps before performing them.

## Uninstall Spiderpool

Understand the running application and understand the impact that uninstalling Spiderpool may have on other related components (such as middleware). Please make sure you fully understand the risks before starting the uninstallation steps.

1. Query the Spiderpool installed in the cluster through `helm ls`

```bash
helm ls -A | grep -i spiderpool
```

2. Uninstall Spiderpool via `helm uninstall`

```bash
helm uninstall <spiderpool-name> --namespace <spiderpool-namespace>
```

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

### Above v1.0.0

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
kubectl get spiderips.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderippools.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderreservedips.spiderpool.spidernet.io -o name | wc -l
kubectl get spiderendpoints.spiderpool.spidernet.io -o name | wc -l
kubectl get spidercoordinators.spiderpool.spidernet.io -o name | wc -l
```

### Below v1.0.0

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
chmod +x cleanCRD.sh && ./cleanCRD.sh
```
18 changes: 18 additions & 0 deletions tools/scripts/cleanCRD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# 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 MutatingWebhookConfiguration | sed '1 d' | awk '{print $1}' | grep sriov-operator-webhook-config | xargs -n 1 -i kubectl delete MutatingWebhookConfiguration {}

kubectl get ValidatingWebhookConfiguration | sed '1 d' | awk '{print $1}' | grep sriov-operator-webhook-config | xargs -n 1 -i kubectl delete ValidatingWebhookConfiguration {}

kubectl get MutatingWebhookConfiguration | sed '1 d' | awk '{print $1}' | grep network-resources-injector-config | xargs -n 1 -i kubectl delete MutatingWebhookConfiguration {}

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 All @@ -22,3 +32,11 @@ kubectl delete crd spiderreservedips.spiderpool.spidernet.io
kubectl delete crd spidersubnets.spiderpool.spidernet.io
kubectl delete crd spidercoordinators.spiderpool.spidernet.io
kubectl delete crd spidermultusconfigs.spiderpool.spidernet.io

# delete all crd of sirov-network-operator
kubectl delete crd sriovibnetworks.sriovnetwork.openshift.io
kubectl delete crd sriovnetworknodepolicies.sriovnetwork.openshift.io
kubectl delete crd sriovnetworknodestates.sriovnetwork.openshift.io
kubectl delete crd sriovnetworkpoolconfigs.sriovnetwork.openshift.io
kubectl delete crd sriovnetworks.sriovnetwork.openshift.io
kubectl delete crd sriovoperatorconfigs.sriovnetwork.openshift.io

0 comments on commit f969112

Please sign in to comment.