KOTS: How do I reset or clean up an install?

I have kots adm and the app installed, how do I clean up these components?

Remove App

If you want to just clean up the app, say for instance you used an incorrect license, you can use the kots remove command. But please note, this will only remove the reference to the app in kots adm db, but the K8s resources of the app need to be cleaned up manually.

kubectl kots remove <app-slug> -n <namespace>

If you would like to clean up kots and the app in its entirety, that depends on the type of environment you have running. A best practice here is to add a specific app=myapp label to all your workloads and k8s objects, so you can clean everything with a single command:

kubectl delete all --selector app=myapp

Note that all does not delete every resource, for example if you also want to clean up secrets, configmaps, roles, etc, you could use something like

kubectl delete all,secret,configmap --selector app=myapp

Remove Kotsadm

Embedded

  • first thing you can try is resetting the node using the tasks.sh reset script.

  • If that does not work, rebuild the VM with a fresh OS and start install from scratch.

Existing

  • Delete the namespace where kotsadm is installed, presumably that is the same namespace where the app is installed as well: kubectl delete ns <namespace>

Note: This will not clean up resources managed outside the namespace such as CRDs.

Hello
Is there no way to completely remove everything that was installed with the kurl installer without re-provision the machine?

Hi @zvikir, please refer to the following documentation on how to remove the admin console and reset a kURL cluster: Deleting the Admin Console and Removing Applications | Replicated Docs

To clarify, the reset script will remove everything that was installed by the kURL installer, and not just the admin console.

1 Like

I’ve created a small script that uses the kots download and kots upload mechanism to fully remove an application from kotsadm, including the deployed resources. The script assumes that all the kots manifest files start with kots- and the application manifest files (including Helm charts) are not nested in subfolders. If that is different , you’ll have to change the find . -maxdepth 1 -type f -name "*" ! -name "kots*" part in the script.

#!/bin/bash
set -e
APP_SLUG=$1
KOTS_NAMESPACE=$2
if [[ -z "$APP_SLUG" ]]; then
   # $APP_SLUG is empty
   echo First arg should be app slug
   exit 1
fi
if [[ -z "$KOTS_NAMESPACE" ]]; then
   # $KOTS_NAMESPACE is empty
   echo Second arg should be kots namespace
   exit 1
fi
echo Removing app $APP_SLUG from namespace $KOTS_NAMESPACE
rm -rf $APP_SLUG
kubectl kots download --namespace $KOTS_NAMESPACE --slug $APP_SLUG
(cd $APP_SLUG/upstream; rm $(find . -maxdepth 1 -type f -name "*" ! -name "kots*"); )
kubectl kots upload --namespace $KOTS_NAMESPACE --slug $APP_SLUG --deploy --skip-preflights ./$APP_SLUG
kubectl kots remove $APP_SLUG --namespace $KOTS_NAMESPACE  --force