Skip to content

Instantly share code, notes, and snippets.

@IronCore864
Created January 31, 2023 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IronCore864/ad21130aa796d407624805c5342201db to your computer and use it in GitHub Desktop.
Save IronCore864/ad21130aa796d407624805c5342201db to your computer and use it in GitHub Desktop.
import subprocess
from concurrent import futures
def get_releases(namespace: str = "default"):
ret = subprocess.run(
["helm", "list", "-n", namespace, "-q"],
capture_output=True,
check=True,
)
return ret.stdout.decode().splitlines()
def helm_uninstall(release: str, namespace: str):
subprocess.run(
["helm", "uninstall", release, "--namespace", namespace],
capture_output=True,
check=True,
)
def uninstall_all_releases_in_ns(namespace: str):
releases = get_releases(namespace)
with futures.ThreadPoolExecutor(max_workers=5) as executor:
future_to_release = {
executor.submit(helm_uninstall, rel, namespace): rel for rel in releases
}
for f in futures.as_completed(future_to_release):
release = future_to_release[f]
print(f"release {release} uninstalled")
if __name__ == "__main__":
uninstall_all_releases_in_ns("default")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment