Skip to main content

Uninstallation

1. Uninstallation Description

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. Two uninstallation methods are available:

  • One-Click Uninstallation (Recommended): Interactive uninstallation via script, confirm each component uninstallation as needed
  • Manual Uninstallation: Uninstall each component step by step, suitable for scenarios where the script cannot complete

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"

Start Uninstallation

The following command is used to quickly uninstall CSGHub and all dependency components installed via one-click deployment. The script will confirm each component before uninstalling.

curl -sfL http://quick-uninstall.opencsg.com | sudo bash

Uninstallation Description

The one-click uninstallation script will confirm and uninstall the following components in order:

  • Uninstall CSGHub Helm chart, clean up related namespaces (csghub/spaces/nfs-provisioner/nvdp), CRDs and CoreDNS custom config, remove Helm repos
  • Remove NVIDIA GPU node labels, uninstall NVIDIA container toolkit and repo files (requires --enable-gpu)
  • Stop NFS server, remove shared directory and export config, uninstall NFS packages
  • Run K3S uninstall script, clean up kubeconfig files
  • Remove sysctl config and /etc/hosts entries added during installation

If a component fails during uninstallation, you can choose to retry, skip, or abort.

More Uninstallation Examples

Depending on your actual deployment, you can add corresponding parameters to the uninstallation command:

Dry-Run Mode

To preview the uninstallation operations without actually executing them:

curl -sfL http://quick-uninstall.opencsg.com | sudo bash -s -- --dry-run

Clean Up GPU Support

If GPU support was enabled during deployment, add this flag to clean up GPU-related components:

curl -sfL http://quick-uninstall.opencsg.com | sudo bash -s -- --enable-gpu

Specify Data Directory

If a non-default data directory was used during deployment, specify the same directory:

curl -sfL http://quick-uninstall.opencsg.com | sudo bash -s -- --data /var/lib/rancher/k3s

Agent Node Uninstallation

If the current node is an Agent node, specify the Server URL:

curl -sfL http://quick-uninstall.opencsg.com | sudo bash -s -- --k3s-server <server_url>

Full Parameter Reference

ParameterDescriptionDefault
--data <data_dir>Data directory used during installation/var/lib/rancher/k3s
--enable-gpuAlso uninstall NVIDIA GPU supportDisabled
--enable-nfs-pvAlso uninstall NFS server and provisionerEnabled
--k3s-server <server_url>Uninstall as an agent node-
--dry-runPrint commands without executing themDisabled
--verboseEnable verbose loggingDisabled

4. Start Uninstallation

First uninstall the CSGHub Helm application, then clean up related namespaces and remaining resources.

# 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

4.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

4.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

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

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

5. Uninstallation Verification

Execute the following commands. No relevant output means the uninstallation is complete and the environment is clean.

# Verify Helm deployment residuals
helm list -A | grep csghub

# Verify K3s is uninstalled
systemctl status k3s || echo "K3s has been uninstalled"
ls /usr/local/bin/k3s || echo "K3s binary file has been deleted"

# Verify namespace residuals
kubectl get ns | grep -E "csghub|nfs|nvdp"

# Verify residual directories are deleted
ls /var/lib/rancher || echo "K3s data directory has been deleted"
ls ~/.kube || echo "kubeconfig has been deleted"

6. Common Issues

  1. K3s uninstallation fails: Execute rm -rf /var/lib/rancher/k3s and then re-run the uninstallation script.
  2. Namespace deletion gets stuck: Execute kubectl delete ns csghub --force --grace-period=0 to force deletion.
  3. 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.

7. 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.