Running Juju with LXD cloud with lxc projects for separate Juju models

LXD projects are a great way to separate machines to different project scopes. Here’s an example on bootstrapping juju to project “juju-proj” in LXD and deploying charms to another LXD project, “mymodel-proj”.

  1. Create the lxc project juju and switch to it.

    lxc project create juju-proj
    
    lxc project switch juju-proj
    
  2. Copy over the default profile from project default to the new project.

    lxc profile show default --project default | lxc profile edit default
    
  3. Bootstrap Juju to localhost LXD.

    juju bootstrap localhost mycontroller --config "project=juju-proj"
    
  4. Verify the controller was created.

    lxc ls
    
    juju status
    
  5. Create a lxc project for the model and switch to it.

    lxc project create mymodel-proj
    
    lxc project switch mymodel-proj
    
  6. Just like in step 2, copy over the default profile from project default to the new project.

    lxc profile show default --project default | lxc profile edit default
    
  7. Set the juju model and config to use mymodel-proj.

    juju add-model mymodel --config "project=mymodel-proj"
    

    Note: Using juju model-config project=mymodel-proj on existing models will not deploy charms to the project.

  8. Deploy a charm.

    juju deploy apache2
    
  9. Check juju status.

    juju status
    
  10. Switch to lxc project and check machines.

    lxc project switch mymodel-proj && lxc ls
    

Reference
Launchpad: Add support for LXD projects
LXD Documentation: How to work with different projects

1 Like