Juju 2.0~ Local LXD provider workflows are awesome!

James Page james.page at ubuntu.com
Wed Feb 3 12:09:01 UTC 2016


Hi All

I've been using Juju 2.0 (built from source with an in-flight patch for LXD
2.0 right now - but that should be resolved soon) with the local LXD
provider on Ubuntu Xenial development to test some work we've been doing to
get OpenStack running on-top of LXD in a single machine.

That's now working quite well (a few rough edges), but is not the main
topic for my post.

1) Multiple models, single controller

Alongside LXD support, you can also create multiple models against a single
controller, so I've been creating models to deploy, test and review
specific pieces of work (reviewing the midonet charms right now for
example):

  juju bootstrap
  juju create-model midonet-review
  juju switch midonet-review

.... and then deploy away;  Not having to re-bootstrap a controller
every-time I want to tear-down and redeploy, or push something new up for
test optimizes my workflow nicely.

2) Tweaking container profiles

For each model, Juju creates a profile in LXD (named juju-<model name>)-
and its quite possible to make additions to that profile for your specific
model requirements - here's the one we wrote for openstack-on-lxd:

name: juju-openstack-on-lxd
config:
  boot.autostart: "true"
  linux.kernel_modules: openvswitch,nbd,ip_tables,ip6_tables
  security.nesting: "true"
  security.privileged: "true"
devices:
  eth0:
    mtu: "9000"
    name: eth0
    nictype: bridged
    parent: lxcbr0
    type: nic
  eth1:
    mtu: "9000"
    name: eth1
    nictype: bridged
    parent: lxcbr0
    type: nic
  kvm:
    path: /dev/kvm
    type: unix-char
  root:
    path: /
    type: disk
  tun:
    path: /dev/net/tun
    type: unix-char

This adds a-lot to the default profile, but at a high level ensures that
each container gets two network interfaces with a high mtu to avoid packet
fragmentation, can access a few devices required for virt networking and
process management - and also switches the container into 'privileged' mode
that we need for Open vSwitch support in a container right now (Tycho is
working on fixing that so we can run unprivileged).  Read more about LXD
profiles here:

  https://github.com/lxc/lxd/blob/master/specs/configuration.md

Editing is super easy - 'lxc profile edit <profile-name>'.

3) Pause/Resume containers

I've found a few bits that LXD provides outside of Juju quite useful as
well - specifically I've been away from regular power for the last few
days, so I've been using the 'pause' feature of containers to freeze
containers, stopping CPU consumption and making my battery last a alot
longer without destroying and re-deploying the environment (which would
consume far more battery anyway) - here's 'pause-juju':

  for container in `lxc list | grep RUNNING | grep juju | awk '{ print $2
}'`; do
      lxc pause $container
  done

and 'resume-juju':

  for container in `lxc list | grep FROZEN | grep juju | awk '{ print $2
}'`; do
      lxc start $container
  done

I'm doing this outside of Juju right now - but I think it would make a
great feature!

All container processes still consume memory, but stop consuming cpu cycles
until resumed.

Oh - and use the ZFS backend for LXD - its superfast!:


https://insights.ubuntu.com/2015/11/06/using-lxd-with-a-file-based-zfs-pool-on-ubuntu-wily/

Hope people find that all useful!

Cheers

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20160203/5f2c5167/attachment.html>


More information about the Juju mailing list