Skip to main content
This guide covers complete removal of the KloudMate Agent from each supported platform. All configuration files, logs, and binaries will be removed.
Data Loss WarningUninstalling the agent will:
  • Stop all telemetry collection
  • Remove configuration files
  • Delete local logs
  • Remove systemd services (Linux)
  • Delete container images (Docker)
Ensure you have backups of any custom configurations before proceeding.

Linux Uninstallation

The KloudMate Agent provides an automated uninstall script for Linux systems.
scripts/uninstall_linux.sh
bash -c "$(curl -L https://cdn.kloudmate.com/scripts/uninstall_linux.sh)"
The script will:
  1. Stop the kmagent service
  2. Disable systemd service
  3. Remove the package via package manager
  4. Clean up configuration files
  5. Remove systemd service files
  6. Clear journal logs

What the Uninstall Script Does

1

Stop and Disable Service

scripts/uninstall_linux.sh
echo "🛑 Stopping KM Agent service..."
sudo systemctl stop kmagent 2>/dev/null || true
sudo systemctl disable kmagent 2>/dev/null || true
2

Remove Systemd Service Files

scripts/uninstall_linux.sh
echo "🗑️  Removing systemd service..."
sudo rm -f /etc/systemd/system/kmagent.service
sudo rm -f /usr/lib/systemd/system/kmagent.service
sudo systemctl daemon-reload
sudo systemctl reset-failed 2>/dev/null || true
3

Clear Journal Logs

scripts/uninstall_linux.sh
echo "📝 Clearing journal logs..."
sudo journalctl --rotate 2>/dev/null || true
sudo journalctl --vacuum-time=1s --unit=kmagent 2>/dev/null || true
4

Remove Package

The script detects your package manager and removes the package:
scripts/uninstall_linux.sh
PKG_MANAGER=""
if command -v apt-get &>/dev/null && dpkg -l kmagent &>/dev/null 2>&1; then
  PKG_MANAGER="apt"
elif command -v dnf &>/dev/null && rpm -q kmagent &>/dev/null 2>&1; then
  PKG_MANAGER="dnf"
elif command -v yum &>/dev/null && rpm -q kmagent &>/dev/null 2>&1; then
  PKG_MANAGER="yum"
fi
Debian/Ubuntu:
scripts/uninstall_linux.sh
sudo apt-get purge -y kmagent 2>/dev/null || sudo dpkg -r kmagent
sudo apt-get autoremove -y 2>/dev/null || true
RHEL/CentOS:
scripts/uninstall_linux.sh
sudo dnf remove -y kmagent
# or
sudo yum remove -y kmagent
5

Clean Up Files and Directories

scripts/uninstall_linux.sh
echo "🗑️  Cleaning up files..."
sudo rm -f /usr/local/bin/kmagent
sudo rm -f /usr/bin/kmagent
sudo rm -rf /etc/kmagent/
sudo rm -rf /var/log/kmagent/
sudo rm -rf /var/lib/kmagent/
sudo rm -f /tmp/kmagent.* /tmp/km-agent.* 2>/dev/null || true

Manual Uninstall (Linux)

If you prefer manual removal:
1

Stop Service

sudo systemctl stop kmagent
sudo systemctl disable kmagent
2

Remove Package

# Purge removes package and config files
sudo apt-get purge -y kmagent
sudo apt-get autoremove -y
3

Remove Service Files

sudo rm -f /etc/systemd/system/kmagent.service
sudo rm -f /lib/systemd/system/kmagent.service
sudo systemctl daemon-reload
4

Clean Up Directories

sudo rm -rf /etc/kmagent/
sudo rm -rf /var/log/kmagent/
sudo rm -rf /var/lib/kmagent/

Verify Removal (Linux)

which kmagent
# Should return: command not found

Security Note (Linux)

The uninstall script includes a security reminder:
scripts/uninstall_linux.sh
echo "🔒 Note: Consider running 'history -c && exit' to clear shell history"
echo "   if API keys were visible in environment variables."
If you exposed API keys in your shell:
history -c  # Clear current session history
rm ~/.bash_history  # Remove persistent history file
exit  # Log out to apply changes

Docker Uninstallation

For Docker installations, remove the container and optionally the image.

Using Uninstall Script

The installation script includes an uninstall function:
scripts/install_docker.sh
bash -c "$(curl -L https://cdn.kloudmate.com/scripts/install_docker.sh)" -- uninstall
The script will:
scripts/install_docker.sh
uninstall_agent() {
    echo "🧹 Uninstalling km-agent..."

    if [ "$(docker ps -aq -f name=km-agent)" ]; then
        docker stop km-agent
        docker rm km-agent
        echo "✅ Container 'km-agent' stopped and removed."
    else
        echo "⚡ No running 'km-agent' container found."
    fi

    if docker image inspect $IMAGE_NAME > /dev/null 2>&1; then
        docker rmi $IMAGE_NAME
        echo "✅ Docker image removed."
    else
        echo "⚡ No '$IMAGE_NAME' image found."
    fi

    echo "✅ Uninstallation complete."
    exit 0
}

Manual Docker Uninstall

1

Stop Container

docker stop km-agent
2

Remove Container

docker rm km-agent
3

Remove Image (Optional)

docker rmi ghcr.io/kloudmate/km-agent:latest
4

Remove Volumes (If Any)

# List volumes
docker volume ls | grep km-agent

# Remove specific volumes
docker volume rm km-agent-data

Force Removal (Docker)

If the container won’t stop:
# Force stop and remove
docker rm -f km-agent

# Remove all related containers
docker ps -a | grep km-agent | awk '{print $1}' | xargs docker rm -f

# Remove all related images
docker images | grep km-agent | awk '{print $3}' | xargs docker rmi -f

Verify Removal (Docker)

docker ps -a -f name=km-agent
# Should return empty

Kubernetes Uninstallation

For Kubernetes deployments, use Helm to uninstall.
helm uninstall kloudmate-release -n km-agent
This removes:
  • DaemonSet
  • Deployment
  • ConfigMaps
  • Services
  • ServiceAccount
  • ClusterRole and ClusterRoleBinding
  • Config Updater deployment

Complete Removal Including CRDs

CRD Removal ImpactRemoving CRDs will delete ALL Instrumentation custom resources in the cluster, not just those created by KloudMate Agent.Only remove CRDs if you’re certain no other OpenTelemetry operators are using them.
1

Uninstall Helm Release

helm uninstall kloudmate-release -n km-agent
2

Remove CRDs

README.md
kubectl delete -f https://raw.githubusercontent.com/kloudmate/km-agent/refs/heads/develop/deployment/helm/km-kube-agent/crds/crd-otel-instrumentation.yaml
Or remove directly:
kubectl delete crd instrumentations.opentelemetry.io
3

Delete Namespace

kubectl delete namespace km-agent
4

Remove ClusterRole and ClusterRoleBinding

These are cluster-scoped and may persist:
kubectl delete clusterrole km-agent-cluster-role
kubectl delete clusterrolebinding km-agent-cluster-role-binding

Remove Instrumentation Annotations

If you instrumented applications using annotations, remove them:
# Remove annotation from deployment
kubectl annotate deployment <deployment-name> \
  instrumentation.opentelemetry.io/inject-java-

# Remove annotation from namespace
kubectl annotate namespace <namespace> \
  instrumentation.opentelemetry.io/inject-java-

Manual Cleanup (Kubernetes)

If Helm is unavailable:
1

Delete DaemonSet

kubectl delete daemonset km-agent -n km-agent
2

Delete Deployment

kubectl delete deployment km-agent-cluster -n km-agent
kubectl delete deployment km-fleet-manager -n km-agent
3

Delete ConfigMaps

kubectl delete configmap km-agent-configmap-daemonset -n km-agent
kubectl delete configmap km-agent-configmap-deployment -n km-agent
4

Delete Services

kubectl delete service km-agent-svc -n km-agent
5

Delete RBAC Resources

kubectl delete serviceaccount km-agent-sa -n km-agent
kubectl delete clusterrole km-agent-cluster-role
kubectl delete clusterrolebinding km-agent-cluster-role-binding
6

Delete Namespace

kubectl delete namespace km-agent

Verify Removal (Kubernetes)

kubectl get namespace km-agent
# Should return: Error from server (NotFound)

Windows Uninstallation

Windows uninstallation is performed through the Windows Control Panel or PowerShell.

Using Control Panel

1

Open Programs and Features

  1. Press Win + R
  2. Type appwiz.cpl and press Enter
2

Find KloudMate Agent

Locate “KloudMate Agent” in the list of installed programs
3

Uninstall

  1. Right-click “KloudMate Agent”
  2. Select “Uninstall”
  3. Follow the uninstall wizard

Using PowerShell

# Stop service
Stop-Service -Name "KloudMate Agent" -Force

# Uninstall via WMI
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match "KloudMate Agent" }
$app.Uninstall()

Manual Cleanup (Windows)

If the uninstaller fails:
# Stop service
Stop-Service -Name "KloudMate Agent"

# Delete service
sc.exe delete "KloudMate Agent"

# Remove installation directory
Remove-Item -Path "C:\Program Files\KloudMate\Agent" -Recurse -Force

# Remove configuration
Remove-Item -Path "C:\ProgramData\KloudMate\Agent" -Recurse -Force

Post-Uninstall Checklist

After uninstalling, verify complete removal:
1

Verify Service/Container Stopped

Linux:
sudo systemctl status kmagent
Docker:
docker ps | grep km-agent
Kubernetes:
kubectl get pods -n km-agent
2

Check for Residual Files

Linux:
find / -name '*kmagent*' 2>/dev/null
find / -name '*km-agent*' 2>/dev/null
3

Verify No Data Being Sent

Check the KloudMate platform to ensure the agent is no longer reporting
4

Clean Up API Keys (Optional)

If you’re not reinstalling, revoke the API key from the KloudMate platform:
  1. Go to https://app.kloudmate.com/settings/
  2. Navigate to API Keys
  3. Revoke the key used for this agent

Reinstallation

If you need to reinstall after uninstalling:

Linux

Install on Linux systems

Docker

Deploy as Docker container

Kubernetes

Deploy to Kubernetes cluster

Troubleshooting Uninstallation

Service Won’t Stop

# Kill process
sudo pkill -9 kmagent

# Force stop service
sudo systemctl kill kmagent
docker kill km-agent
docker rm -f km-agent
kubectl delete pod <pod-name> -n km-agent --force --grace-period=0

Package Won’t Remove

Linux:
# Debian/Ubuntu - force removal
sudo dpkg --remove --force-remove-reinstreq kmagent

# RHEL/CentOS - force removal
sudo rpm -e --nodeps kmagent

Namespace Stuck Terminating (Kubernetes)

If the namespace won’t delete:
# Get namespace JSON
kubectl get namespace km-agent -o json > km-agent-ns.json

# Edit to remove finalizers
vim km-agent-ns.json
# Remove "finalizers" section

# Apply without finalizers
kubectl replace --raw "/api/v1/namespaces/km-agent/finalize" -f ./km-agent-ns.json

Data Retention

Platform Data RetentionUninstalling the agent only removes it from your infrastructure. Data already collected and sent to the KloudMate platform will be retained according to your plan’s retention policy.To delete historical data, contact [email protected].

Support

If you encounter issues during uninstallation:

GitHub Issues

Report uninstallation problems

Email Support

Next Steps

After uninstalling:

Reinstall

Reinstall the agent if needed

Troubleshooting

Get help with issues

Build docs developers (and LLMs) love