Juju is a deploy tool which supports a very wide range of cloud providers,
like AWS, Azure, Google Cloud Platform, MAAS and LXD. This artcle will focus on
how to build an OpenStack test environment using Juju and LXD.
Run below command to config lxd setting step by step
12345678
$ sudo lxd init
Do you want to configure a new storage pool (yes/no) [default=yes]?
Name of the storage backend to use (dir or zfs) [default=dir]:
Would you like LXD to be available over the network (yes/no) [default=no]?
Do you want to configure the LXD bridge (yes/no) [default=yes]?
Warning: Stopping lxd.service, but it can still be activated by:
lxd.socket
LXD has been successfully configured.
Once the install is done, we can bootstrap a new controller using LXD. This
means that juju will create a new LXD container for management service.
We can create a controller called juju-controller with below command
1234567891011121314151617181920
$ juju bootstrap localhost juju-controller
Since Juju 2 is being run for the first time, downloading latest cloud information.
Fetching latest public cloud list...
Your list of public clouds is up to date, see `juju clouds`.
Creating Juju controller "juju-controller" on localhost/localhost
Looking for packaged Juju agent version 2.3.7 for amd64
To configure your system to better support LXD containers, please see: https://github.com/lxc/lxd/blob/master/doc/production-setup.md
Launching controller instance(s) on localhost/localhost...
- juju-9ccefc-0 (arch=amd64) s)
Installing Juju agent on bootstrap instance
Fetching Juju GUI 2.12.3
Waiting for address
Attempting to connect to 10.229.139.129:22
Connected to 10.229.139.129
Running machine configuration script...
Bootstrap agent now started
Contacting Juju controller at 10.229.139.129 to verify accessibility...
Bootstrap complete, "juju-controller" controller now available
Controller machines are in the "controller" model
Initial model "default" added
After this, we can see a new LXD container is running.
123456
$ lxc list
+---------------+---------+-----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+---------------+---------+-----------------------+------+------------+-----------+
| juju-9ccefc-0 | RUNNING | 10.229.139.129 (eth0) | | PERSISTENT | 0 |
+---------------+---------+-----------------------+------+------------+-----------+
And run juju status to check there is nothing running yet.
123456789
$ juju status
Model Controller Cloud/Region Version SLA
default juju-controller localhost/localhost 2.3.7 unsupported
App Version Status Scale Charm Store Rev OS Notes
Unit Workload Agent Machine Public address Ports Message
Machine State DNS Inst id Series AZ Message
OK, now we are ready for deploy minecraft server!
Run below command to tell juju you want to deploy it. and it should return
immediately. However it doesn’t mean the service is ready. Run juju status to
check the status.
123456789101112
$ juju status
Model Controller Cloud/Region Version SLA
default juju-controller localhost/localhost 2.3.7 unsupported
App Version Status Scale Charm Store Rev OS Notes
minecraft waiting 0/1 minecraft jujucharms 3 ubuntu
Unit Workload Agent Machine Public address Ports Message
minecraft/0 waiting allocating 0 10.229.139.124 waiting for machine
Machine State DNS Inst id Series AZ Message
0 pending 10.229.139.124 juju-72dd35-0 trusty Running
From above we can see juju is working on creating the server. And we also can
check a new container is created for minecraft server, by lxc list command.
After a while, the deploying is done and the service is active.
123456789101112
$ juju status
Model Controller Cloud/Region Version SLA
default juju-controller localhost/localhost 2.3.7 unsupported
App Version Status Scale Charm Store Rev OS Notes
minecraft active 1 minecraft jujucharms 3 ubuntu
Unit Workload Agent Machine Public address Ports Message
minecraft/0* active idle 0 10.229.139.124 25565/tcp Ready
Machine State DNS Inst id Series AZ Message
0 started 10.229.139.124 juju-72dd35-0 trusty Running
Now you can start your minecraft client, and point to 10.229.139.124 on port
25565 to play with your all new minecraft server!
If you want to get rid of it, just run below command.
Every service or server related to minecraft server will be gone.
1
$ juju destroy-service minecraft
You can also destory juju controller and all service/server created by it.
The easiest way to destory everything is as below.
1234567891011
$ juju destroy-controller juju-controller --destroy-all-models
WARNING! This command will destroy the "juju-controller" controller.
This includes all machines, applications, data and other resources.
Continue? (y/N):y
Destroying controller
Waiting for hosted model resources to be reclaimed
Waiting on 1 model, 1 machine, 1 application
Waiting on 1 model, 1 machine, 1 application
Waiting on 1 model, 1 machine
All hosted models reclaimed, cleaning up controller machines
We can confirm that all containers are gone.
1234
$ lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+