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>
Warning!: Destroying a service which has active relations with another running service will break that relation. This can cause errors in both services, as such review and potentially destroy any relationships first if.
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.
Note: Destroying a service removes that service, but not any nodes which may have been created for it to run on. This is juju's way of preserving data to the best it's ability. See Destroying Machines for additional details.
Destroying 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 units. More details can be found in the Scaling Services section.
Destroying 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, or any one of these other methods:
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.
Removing Relations
To remove relations between deployed services, you should see the docs section on charm relationships.