While messing around with juju 1.17.x I managed to stumble across a setup that allows me to deploy both LXC and KVM containers in a single environment.
Pre-reqs
- Juju v1.17 or higher
- libvirt-bin
- lxc
- Ubuntu Saucy or higher (only one I tested this on)
The juju environments.yaml
Very simple configuration for this
default: local
environments:
local:
type: local
network-bridge: virbr0
Bootstrap and Deploy
$ juju bootstrap
$ juju deploy mysql --to kvm:0
$ juju deploy wordpress
What this does is deploy mysql onto a KVM instance within Machine 0 and deploys wordpress onto an LXC instance which is Machine 1 by default. The juju status output should look similar to this:
environment: local
machines:
"0":
agent-state: started
agent-version: 1.17.5.1
dns-name: localhost
instance-id: localhost
series: saucy
containers:
0/kvm/0:
agent-state: started
agent-version: 1.17.5.1
dns-name: 192.168.122.233
instance-id: juju-machine-0-kvm-0
series: precise
hardware: arch=amd64 cpu-cores=1 mem=512M root-disk=8192M
"1":
agent-state: started
agent-version: 1.17.5.1
dns-name: 192.168.122.204
instance-id: adam-local-machine-1
series: precise
hardware: arch=amd64
services:
mysql:
charm: cs:precise/mysql-38
exposed: false
relations:
cluster:
- mysql
db:
- wordpress
units:
mysql/0:
agent-state: installed
agent-version: 1.17.5.1
machine: 0/kvm/0
public-address: 192.168.122.233
wordpress:
charm: cs:precise/wordpress-21
exposed: true
relations:
db:
- mysql
loadbalancer:
- wordpress
units:
wordpress/0:
agent-state: started
agent-version: 1.17.5.1
machine: "1"
open-ports:
- 80/tcp
public-address: 192.168.122.204
You can also verify the instances via virsh and lxc-ls –fancy
$ virsh list
Id Name State
----------------------------------------------------
55 juju-machine-0-kvm-0 running
$ sudo lxc-ls --fancy
NAME STATE IPV4 IPV6 AUTOSTART
---------------------------------------------------------------
adam-local-machine-1 RUNNING 192.168.122.204 - YES
Since we set our network-bridge to virbr0 those instances happily talk to each other.
Additional things you can do
Deploying all kvm instances into Machine 0 is as simple as:
$ juju deploy mongodb --to kvm:0
$ juju deploy rails --to kvm:0
$ juju deploy wikipedia --to kvm:0
Disclaimer
- Is this a supported configuration? Nope.
- Is it crazy to do something like this? Maybe.
- Should I do this at my own risk? Hell yes.