Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread James Page
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-)-
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 '.

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
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread Jorge O. Castro
On Wed, Feb 3, 2016 at 1:09 PM, James Page  wrote:
> Hope people find that all useful!

Indeed, we also have fresh documentation thanks to Peter Matulis. I've
been using these all week to spin up on lxd and juju:

https://jujucharms.com/docs/devel/config-LXD

As always everyone please feel free to open a PR or file an issue.

Also a huge +1 to the LXD/ZFS/Juju combination; all of these
performance improvements across the different parts of the stack are
really coming together.

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread Mark Shuttleworth
On 03/02/16 12:09, James Page wrote:
>   juju create-model midonet-review
>   juju switch midonet-review

Thanks for the feedback James, it's great to see these bits coming
together so nicely :)

Should we automatically switch to a new model when you create it? I
suspect the common case is create-model-then-work-in-it rather than
create-model-then-do-something-else.

Thoughts?
Mark

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread Louis Bouchard
Hi,

Le 03/02/2016 14:23, Mark Shuttleworth a écrit :
> On 03/02/16 12:09, James Page wrote:
>>   juju create-model midonet-review
>>   juju switch midonet-review
> 
> Thanks for the feedback James, it's great to see these bits coming
> together so nicely :)
> 
> Should we automatically switch to a new model when you create it? I
> suspect the common case is create-model-then-work-in-it rather than
> create-model-then-do-something-else.
> 

Don't we all love 'git checkout -b' to land into the newly created branch ???

How about juju create-model -b  ;-)


> Thoughts?
> Mark
> 

...Louis

-- 
Louis Bouchard
Software engineer, Cloud & Sustaining eng.
Canonical Ltd
Ubuntu developer   Debian Maintainer
GPG : 429D 7A3B DD05 B6F8 AF63  B9C4 8B3D 867C 823E 7A61

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread Antonio Rosales
On Wed, Feb 3, 2016 at 1:09 PM, James Page  wrote:
> 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.

This is solid, thanks for sharing here.

-Antonio

>
> 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-)- 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 '.
>
> 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
>
>
>
> --
> Juju mailing list
> Juju@lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>



-- 
Antonio Rosales
Ecosystem Engineering
Canonical

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread Rick Harding
Yes it's intended to auto switch for you. If it does not we need to correct
it.

On Wed, Feb 3, 2016, 2:49 PM James Page  wrote:

> On Wed, 3 Feb 2016 at 13:23 Mark Shuttleworth  wrote:
>
>> On 03/02/16 12:09, James Page wrote:
>> >   juju create-model midonet-review
>> >   juju switch midonet-review
>>
>> Thanks for the feedback James, it's great to see these bits coming
>> together so nicely :)
>>
>> Should we automatically switch to a new model when you create it? I
>> suspect the common case is create-model-then-work-in-it rather than
>> create-model-then-do-something-else.
>
>
> Actually we do the auto switch already - the switch in my example is not
> required (just tested with a new model).
> --
> Juju mailing list
> Juju@lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/juju
>
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: Juju 2.0~ Local LXD provider workflows are awesome!

2016-02-03 Thread James Page
On Wed, 3 Feb 2016 at 13:23 Mark Shuttleworth  wrote:

> On 03/02/16 12:09, James Page wrote:
> >   juju create-model midonet-review
> >   juju switch midonet-review
>
> Thanks for the feedback James, it's great to see these bits coming
> together so nicely :)
>
> Should we automatically switch to a new model when you create it? I
> suspect the common case is create-model-then-work-in-it rather than
> create-model-then-do-something-else.


Actually we do the auto switch already - the switch in my example is not
required (just tested with a new model).
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju