Skip to content

Implement option to uninstall Stacks and Demos #187

Description

@sbernauer

Comment with more information on the deletion status/process: #187 (comment)


Update after a discussion on 2025-11-26:

In case, a user wants to try out a demo and uninstall it afterwards, it should be documented, how to do this. stackablectl should provide an option for it.

  • All resources with a Stackable label should be removed, including the data (PersistentVolumes). That means that all top-level resources, which are not (indirectly) owned by a Stackable labeled resource, must be labeled accordingly, e.g. the namespace a demo is installed in.
  • Demos and stacks should be installed in the non-default namespace.
  • External tools like PostgreSQL in the demo/stacks namespace will therefore also be removed.
  • The first version of this removal "tool" shows a warning and provides no option to be less destructive and keep resources.

Initial description:

As a user
I want to be able to uninstall a stack or demo by itself, after I'm done looking at it
to have a clean cluster again and not have to remove things manually, which is error prone.

  • What should be uninstalled, should operators be left behind?
  • What about multiple stacks in the same namespace? What about shared things like a ZooKeeper in two stacks. we could try and have only one ZK and label it as being part of two stacks, in a sort of dependency tree.
  • Should a demo be always in a dedicated namespace? Deleting a namespace will not delete cluster-scoped resources
  • What about removing Redis/Postgres etc. that is part of a demo?
  • What about data? I.e. PVCs? maybe there could be uninstall vs purge and purge also removes data.
  • What about cluster scoped resources? How do we make sure they do not comflict with each other?

Removing

  • some Manifests need to be deleted
  • Helm stuff needs to be uninstalled (i.e. Postgres)

Related ADR: https://docs.stackable.tech/home/stable/contributor/adr/adr031-resource-labels

Random unrelated code dump, do not execute :P

#!/usr/bin/env bash
set -euo pipefail

CONTEXT=$(kubectl config current-context)
CLUSTER=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$CONTEXT\")].context.cluster}")

echo "You are about to run a destructive operation"
echo "Current kube context : $CONTEXT"
echo "Current cluster      : $CLUSTER"
echo

read -r -p "Do you want to continue? (y/N): " CONFIRM

if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
  echo "Aborted."
  exit 1
fi

echo "Continuing..."

kubectl delete ns stackable-operators || true
kubectl get crd -o name | grep stackable | xargs kubectl delete || true
kubectl delete --all pvc || true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions