Destroy Stuff
Juju isn't just about magically spinning up services as and when you need them, it is also about quickly, sanely and efficiently destroying everything when you no longer need it. This section deals with the sort of things you can ruthlessly destroy, and how to go about it.
Destroying/Removing Services
Once a service is no longer required it can be removed with a simple command.
juju destroy-service <service-name>
Before you take this step though, it is important to remove any relationships so that it can be removed cleanly, otherwise an error state may exist elsewhere.
A service can take a while to "die", but if running a juju status reveals that the service is listed as dying, but also reports an error state, then the zombied service will still be hanging around. See "Why won't it just die?" in the troubleshooting section.
Warning!:Destroying a service which has active relations with another running service can cause errors in both services. You should destroy any relationships first if possible.
Note: Destroying a service removes that service, but not any nodes which may have been created for it to run on.
Destroying/Removing Units
It is also possible to spin down individual units, or a sequence of units running a service:
juju remove-unit mediawiki/1
The 'remove-unit' command is an alias for 'destroy-unit', and can be used interchangeably, so the above is identical to:
juju destroy-unit mediawiki/1
If you wish to remove more than one unit, you may list them all following the command:
juju remove-unit mediawiki/1 mediawiki/2 mediawiki/3 mysql/2 ...
Note: As with destroying a service, removing units will NOT actually remove any instances which were created, it only removes the service unitsm.
Destroying/Removing machines
Instances or machines which have no currently assigned workload can be removed from your cloud using the following command:
juju destory-machine <number>
A machine which currently idle will be removed almost instantaneously from the cloud, along with anything else which may have been on the instance which juju was not aware of. To prevent accidents and awkward moments with running services, it is not possible to remove an instance which is currently allocated to a service. If you try to do so, you will get a polite error message in the form:
error: no machines were destroyed: machine 3 has unit "mysql/0" assigned
Destroying Environments
To completely remove and terminate all running services, the instances they were running on and the bootstrap node itself, simply run the command:
juju destroy-environment
This will completely remove all instances running under the current environment profile. You can of course specify a different environment profile using the -e switch:
juju destroy-environment -e mycloud
You should be pretty sure that this is what you want to do, as there is no undo command! Everything in the selected environment will be removed.
Destroying Relations
To remove relations between deployed services, you should see the docs section on charm relationships
.