Uninstallation
1. Uninstallation Instructions
This document is used to completely uninstall the CSGHub application, K3s cluster, and related dependency components deployed through the quick_install.sh script. It is suitable for scenarios where a thorough environment cleanup and redeployment are required.
Important Warning: The uninstallation operation is irreversible. It will delete all CSGHub data (database, models, configurations, etc.), K3s cluster resources, and related storage files. Please be sure to back up important data before executing.
2. Pre-uninstallation Preparation
Confirm the current deployment status (verify resources to be uninstalled):
# View CSGHub Helm deployment status
helm list -n csghub
# View K3s running status
systemctl status k3s (Server node)
systemctl status k3s-agent (Agent node)
# View remaining Pods/namespaces
kubectl get pods -A | grep -E "csghub|nfs|nvdp"
kubectl get ns | grep -E "csghub|nfs-provisioner|nvdp"
3. Start Uninstallation
3.1 Uninstall CSGHub Application and Related Components
First uninstall the CSGHub Helm application, then clean up related namespaces and remaining resources to avoid resource occupation.
# 1. Uninstall CSGHub Helm Release (core operation)
helm uninstall csghub -n csghub
# 2. Delete CSGHub related namespace (completely clean up all resources under this namespace)
kubectl delete ns csghub --ignore-not-found
# 3. Clean up CSGHub dependency namespaces (NFS, GPU plugin related)
kubectl delete ns nfs-provisioner --ignore-not-found
kubectl delete ns nvdp --ignore-not-found
# 4. Clean up CSGHub related CRDs (to avoid residual impact on subsequent deployments)
kubectl delete crd -l app.kubernetes.io/name=csghub --ignore-not-found
3.2 Uninstall K3s Cluster
Only execute when you need to completely delete the K3s cluster. After uninstallation, all cluster resources (Pods, Services, storage, etc.) will be deleted.
# Uninstall K3s Server node (default operation for single-node deployment)
/usr/local/bin/k3s-uninstall.sh
# For Agent nodes, execute the following command to uninstall
/usr/local/bin/k3s-agent-uninstall.sh
3.3 Clean Up Residual Data and Dependency Files
Delete residual directories and files related to K3s, CSGHub, and Helm to ensure the environment is completely clean.
# 1. Delete K3s data directory (core data, including cluster configuration and storage data)
rm -rf /var/lib/rancher /etc/rancher
# 2. Delete CSGHub residual directory
rm -rf /opt/csghub
# 3. Delete kubeconfig and Helm configuration directories
rm -rf ~/.kube ~/.helm
# 4. Delete Helm repository cache (optional, skip if you need to keep other Helm repositories)
rm -rf /root/.cache/helm
# 5. Delete uninstallation logs and login information files (generated by the deployment script)
rm -rf quick-install.log login.txt
3.4 Clean Up NFS Related Residuals
Delete NFS shared directories and services to avoid occupying disk space.
# Stop NFS service
systemctl stop nfs-kernel-server (Ubuntu/Debian)
systemctl stop nfs (CentOS/Alpine)
# Disable NFS service auto-start on boot
systemctl disable nfs-kernel-server (Ubuntu/Debian)
systemctl disable nfs (CentOS/Alpine)
# Delete NFS shared directory
rm -rf /data/sharedir
# Delete NFS configuration file
sed -i "\|/data/sharedir|d" /etc/exports 2>/dev/null || true
exportfs -rav
3.5 Clean Up NVIDIA GPU Related Components (if GPU support was enabled)
Uninstall NVIDIA container toolkit and related dependencies. Suitable for scenarios where GPU functionality is no longer needed.
# Ubuntu/Debian systems
apt-get remove -y nvidia-container-toolkit nvidia-container-runtime libnvidia-container-tools libnvidia-container1
rm -rf /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
rm -rf /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
# CentOS/RHEL systems
dnf remove -y nvidia-container-toolkit nvidia-container-runtime libnvidia-container-tools libnvidia-container1
rm -rf /etc/yum.repos.d/nvidia-container-toolkit.repo
dnf makecache
4. Uninstallation Verification
Execute the following commands. No relevant output means the uninstallation is complete and the environment is clean.
# Verify if Helm deployment has residuals
helm list -A | grep csghub
# Verify if K3s is cleanly uninstalled
systemctl status k3s || echo "K3s has been uninstalled"
ls /usr/local/bin/k3s || echo "K3s binary file has been deleted"
# Verify if related namespaces have residuals
kubectl get ns | grep -E "csghub|nfs|nvdp"
# Verify if residual directories have been deleted
ls /var/lib/rancher || echo "K3s data directory has been deleted"
ls ~/.kube || echo "kubeconfig has been deleted"
5. Common Problem Handling
- K3s uninstallation fails: Execute rm -rf /var/lib/rancher/k3s and then re-execute the uninstallation script.
- Namespace deletion gets stuck: Execute kubectl delete ns csghub --force --grace-period=0 to force deletion.
- Residual files cannot be deleted: Confirm no processes are occupying the files, use lsof | grep filename to find occupying processes, and delete after ending them.
6. Notes
- The uninstallation operation is irreversible. If necessary, be sure to back up important data such as databases and configuration files in advance.
- If you only need to redeploy CSGHub, there is no need to uninstall K3s. Just execute Helm uninstallation and namespace deletion.
- All commands must be executed with root privileges to avoid incomplete uninstallation due to insufficient permissions.