Juju should be able to use a locally installed LXD image

Bug #1650651 reported by Bryan Quigley
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Released
High
Andrew Wilkins

Bug Description

I should be able to manually import an image into LXD and have Juju use that.

= Setup (sudo lxd init previously done) =
wget https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-lxd.tar.xz https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-root.tar.xz
lxc image import xenial-server-cloudimg-amd64-lxd.tar.xz xenial-server-cloudimg-amd64-root.tar.xz --alias ubuntu-xenial

You should then be able to launch an image:
lxc launch ubuntu-xenial

= Go "Offline" =

Edit /etc/hosts and add:
127.0.0.1 cloud-images.ubuntu.com
127.0.0.1 streams.ubuntu.com

= Bug =
Then you try with juju bootstrap
$ juju bootstrap
Since Juju 2 is being run for the first time, downloading latest cloud information.
Fetching latest public cloud list...
Updated your list of public clouds with 1 cloud region added:

    added cloud region:
        - aws/us-east-2
Clouds
aws
aws-china
aws-gov
azure
azure-china
cloudsigma
google
joyent
localhost
rackspace

Select a cloud [localhost]:

Enter a name for the Controller [localhost-localhost]:

Creating Juju controller "localhost-localhost" on localhost/localhost
Looking for packaged Juju agent version 2.0.0 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...
ERROR failed to bootstrap model: cannot start bootstrap instance: image not imported!

Revision history for this message
Bryan Quigley (bryanquigley) wrote :

Actually this is also reproducible by doing a juju bootstrap, and then "going offline" even if it Juju downloaded the image files itself.

tags: added: lxd lxd-provider
Changed in juju:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.2.0
Curtis Hovey (sinzui)
Changed in juju:
milestone: 2.2-beta1 → 2.2-beta2
Revision history for this message
Andrew Wilkins (axwalk) wrote :

As of Juju 2.1, Juju will look for an local image with the alias "juju/$series/$arch", and use that if it exists; else it will fetch it from cloud-images and give it that alias.

So change your import command to:

    lxc image import xenial-server-cloudimg-amd64-lxd.tar.xz xenial-server-cloudimg-amd64-root.tar.xz --alias juju/xenial/amd64.

and you should be good.

Changed in juju:
assignee: nobody → Andrew Wilkins (axwalk)
status: Triaged → Fix Released
Changed in juju:
milestone: 2.2-beta2 → 2.1.0
Revision history for this message
feng xia (fengxia41103) wrote :

I created a local image as instructed above,
but deploying a charm to `trusty` series and watching `lxc image list`, it will still download `ubuntu-trusty` instead of using this local image.

Did I miss something?

------------------------------------------------------------------------------------
fengxia@local-charmdev:~/workspace/wss$ lxc image info trusty
Fingerprint: 203a6ae7d45cbe5c1411ad3f17b9b2429cb5ddfec69019fa96ce5710c4871504
Size: 365.92MB
Architecture: x86_64
Public: no
Timestamps:
    Uploaded: 2017/08/31 14:32 UTC
    Expires: never
    Last used: never
Properties:
    label: release
    os: ubuntu
    release: trusty
    serial: 20170811
    version: 14.04
    architecture: amd64
    description: ubuntu 14.04 LTS amd64 (release) (20170811)
Aliases:
    - gold-image (gold-image)
    - trusty (trusty)
    - juju/trusty/amd64 (juju/trusty/amd64)
Auto update: disabled

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Feng, which version of Juju are you using?
What steps did you take, what did you expect to happen, and what happened?

Revision history for this message
feng xia (fengxia41103) wrote :

Version:

fengxia@local-charmdev:~/workspace/wss$ juju --version
2.0.2-xenial-amd64

Steps I took:

1. create a vanilla `trusty` LXD container named `gold`
2. ssh into `gold` container, `apt install python python-dev...`
3. in terminal, `$ lxc snapshot gold`, this created a snapshot, can be viewed from `$ lxc info gold`.
4. in terminal, `$ lxc publish gold/snap0 --alias gold-image` (according to https://insights.ubuntu.com/2016/04/01/lxd-2-0-image-management-512/). This create a new image `gold-image` based on container snapshot (created in #3).
5. `$ lxc image alias create juju/trusty/amd64`, based on recommendation on this thread. Verify using `$ lxc image info gold-image`. Similarly, I added alias `ubuntu-trusty`, `trusty`.
6. `$ lxc image delete ubuntu-trusty`. This is to delete the default ubuntu-trusty image downloaded by LXD.

So at this point, there should be one image (`$ lxc image list`) that has alias of `trusty` related name/alias.

Expect:

1. When `$ juju deploy [charm] --series trusty`, it will use `gold-image` as `trusty` image to create new machine.

What happened:

1. it will download `ubuntu-trusty` image (`$ lxc image list` will show this new image after a few minutes of downloading), then use this image to create a new machine.

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Thanks for your response. Juju 2.1.0 or greater is required for this to work.

Revision history for this message
feng xia (fengxia41103) wrote :

Upgraded juju to version:

```
fengxia@local-charmdev:~$ juju --version
2.2.2-xenial-amd64
```

Issuing `juju deploy` command, under the `Message`, it says `copying image for ubuntu-trusty from https://cloud-images.ubuntu.com/release/: rootfs: 79%`.

Below is my local LXD image:

```
fengxia@local-charmdev:~$ lxc image info juju/trusty/amd64
Fingerprint: 203a6ae7d45cbe5c1411ad3f17b9b2429cb5ddfec69019fa96ce5710c4871504
Size: 365.92MB
Architecture: x86_64
Public: no
Timestamps:
    Uploaded: 2017/08/31 14:32 UTC
    Expires: never
    Last used: never
Properties:
    version: 14.04
    architecture: amd64
    description: ubuntu 14.04 LTS amd64 (release) (20170811)
    label: release
    os: ubuntu
    release: trusty
    serial: 20170811
Aliases:
    - juju/trusty/amd64 (juju/trusty/amd64)
Auto update: disabled
```

Any pointer?

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Did you update just the client, or did you also rebootstrap/upgrade the controller? The controller is the main thing that needs to be 2.1+.

Revision history for this message
feng xia (fengxia41103) wrote :

Verified.

1. Update juju to 2.2.2
2. re-bootstrap a controller

It is now using a local image w/ alias `juju/trusty/amd64`.

Thank you Juju.

Revision history for this message
alam (alam004) wrote :

Hi,

Is it possible to bootstrap in offline mode using juju version 2.5.7? Or this procedure is not supporting? @Andrew Wilkins (axwalk)

Revision history for this message
Alireza Nasri (sysnasri) wrote :

I want to know this approach works in a situation which maas provisions a server and within this server lxd will be installed and provisions some LDX containers, uses my lxd image which is in juju client machine?

Revision history for this message
Pen Gale (pengale) wrote :

Discussion about the above comment on discourse here: https://discourse.charmhub.io/t/local-lxd-image-server/3929/5

Revision history for this message
Cong Phuoc Hoang (hoangphuoc) wrote :

it still doesn't work on juju version 2.8.9 :(

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.