Is there a quick and easy way to remove a deployed bundle in one shot? For example, I’m trying to tear down a charmed k8s deployment. I’ve been running juju remove-application easyrsa
, juju remove-application etcd
, etc. This is a bit painful, but also it doesn’t seem to be working since some of the apps get into a strange “waiting” state. I’m having a hard time finding a way to tear down the bundle short of just destroying the model.
Yeah we could use this on my end too! A small libjuju helper script that would take the location to bundle file as an input arg, enumerate the apps and run remove-applicaton
on them
Here is a simple script that should do the trick, using libjuju and pyyaml:
#!/usr/bin/python3
import sys
from juju import loop
from juju.model import Model
import yaml
async def clear_bundle(bundle):
model = Model()
await model.connect()
app_names = bundle['applications'].keys()
apps = [app for id, app in model.applications.items() if id in app_names]
for app in apps:
await app.remove()
def main():
with open(sys.argv[1], 'r') as bundle_file:
bundle = yaml.load(bundle_file)
loop.run(clear_bundle(bundle))
if __name__ == '__main__':
main()
2 Likes