Self-Managed Kubernetes Cleanup

This guide provides instructions for completely removing Observo Site and the Kubernetes cluster from your nodes. Follow the appropriate section based on your installation method.

Pre-cleanup Steps

1. Back Up Important Data

# Backup Kubernetes configurations
kubectl get all -n observo-client -o yaml > observo-backup.yaml

# Backup persistent data (if needed)
kubectl get pv,pvc -A -o yaml > storage-backup.yaml

2. Remove Site Registration

  1. Access Observo Cloud interface

  2. Navigate to Settings → Sites

  3. Remove site registration

Cleanup for microk8s Cluster

1. Remove Observo Components

# Remove helm releases
microk8s helm list -n observo-client
microk8s helm uninstall observo-site -n observo-client

# Delete namespace
microk8s kubectl delete namespace observo-client

2. Leave Cluster (Secondary Nodes)

# On each secondary node
microk8s leave

3. Remove microk8s

# On all nodes
sudo snap remove microk8s --purge

4. Clean Up System Files

# Remove configuration files
rm -rf ~/.kube
sudo rm -rf /var/snap/microk8s
sudo rm -rf /root/.kube

# Remove CNI configurations
sudo rm -rf /etc/cni/net.d/*

Cleanup for k3s Cluster

1. Remove Observo Components

# Remove helm releases
helm list -n observo-client
helm uninstall observo-site -n observo-client

# Delete namespace
kubectl delete namespace observo-client

2. Uninstall k3s

# On worker nodes (if any)
/usr/local/bin/k3s-agent-uninstall.sh

# On server nodes
/usr/local/bin/k3s-uninstall.sh

3. Clean Up System Files

# Remove k3s data
sudo rm -rf /var/lib/rancher/k3s
sudo rm -rf /etc/rancher/k3s

# Remove configuration
rm -rf ~/.kube
sudo rm -rf /root/.kube

Network Cleanup

1. Remove CNI Interfaces

# Remove CNI configurations
sudo ip link delete cni0
sudo ip link delete flannel.1

# Clean up iptables
sudo iptables -F
sudo iptables -X

2. Cleanup nginx Configuration

# Remove nginx stream configuration
sudo rm -f /etc/nginx/conf.d/stream/tcp-proxy.conf

# Restart nginx
sudo systemctl restart nginx

System Cleanup

1. Remove System Services

# Remove systemd services
sudo rm -f /etc/systemd/system/k3s*.service
sudo rm -f /etc/systemd/system/microk8s*.service
sudo systemctl daemon-reload

2. Clean Container Runtime

# Remove containerd data
sudo rm -rf /var/lib/containerd
sudo rm -rf /run/containerd

# Remove container storage
sudo rm -rf /var/lib/docker

Verify Cleanup

1. Check Processes

# Verify no k8s processes
ps aux | grep -E 'k3s|microk8s|kube|containerd'

2. Check Network

# Verify network interfaces
ip link show

# Check ports
netstat -tulpn

For additional assistance, refer to:

Last updated

Was this helpful?