Uninstall cnspec
Remove cnspec from a device, including its service and automatic updater, and remove the Mondoo Kubernetes Operator from a cluster
If you need to remove cnspec from a host, this page walks through it cleanly: log out of Mondoo Platform, remove the automatic updater, uninstall the packages, and clean up the leftover repository and configuration.
The install command from the Mondoo App runs cnspec as a service and adds an automatic updater: a weekly cron job on Linux, a launchd job on a Mac where it installs the .pkg package, or a scheduled task on Windows. The updater runs the install script again, so remove it as shown below, or it reinstalls cnspec.
If cnspec is running as a service, stop and disable it first. Uninstalling requires administrator or sudo privileges.
Log out and uninstall
-
Log out the cnspec client:
cnspec logout --force -
Remove the automatic updater, if the host has one:
sudo rm -f /etc/cron.weekly/mondoo-update /var/log/mondoo-updater.log -
Uninstall the packages.
mondoois a metapackage; thecnspecandmqlpackages hold the binaries and the cnspec service:sudo apt remove mondoo cnspec mql sudo apt autoremove -
Remove the repository and signing key:
sudo rm /usr/share/keyrings/mondoo-archive-keyring.gpg sudo rm -f /etc/apt/sources.list.d/mondoo.sources /etc/apt/sources.list.d/mondoo.list -
If present, remove the system-wide configuration and providers, and your user configuration:
sudo rm -rf /etc/opt/mondoo/ /opt/mondoo/ rm -rf ~/.config/mondoo/
Uninstall the Mondoo Kubernetes Operator
To remove the Mondoo Kubernetes Operator from a cluster:
-
Delete every audit configuration and the operator configuration, so the operator can clean up the scan workloads it created. To list them:
kubectl get mondooauditconfigs.k8s.mondoo.com,mondoooperatorconfigs.k8s.mondoo.com -ATo delete them:
kubectl delete mondooauditconfigs.k8s.mondoo.com --all --all-namespaces kubectl delete mondoooperatorconfigs.k8s.mondoo.com --all -
Uninstall the operator with the same tool you installed it with. For a Helm install:
helm uninstall mondoo-operator --namespace mondoo-operatorFor a kubectl install:
kubectl delete -f https://install.mondoo.com/k8s/operator -
In the Mondoo App, remove the Kubernetes integration. Read Remove a Kubernetes integration.
If the mondoo-operator namespace stays in the Terminating state, an audit configuration still has a finalizer, usually because the operator stopped before it could clean up. Find the remaining objects, then remove the finalizer from each audit configuration:
kubectl get mondooauditconfigs.k8s.mondoo.com -n mondoo-operator
kubectl patch mondooauditconfigs.k8s.mondoo.com AUDIT_CONFIG_NAME -n mondoo-operator \
--type=merge -p '{"metadata":{"finalizers":null}}'Last updated on