Deploy Charm to LXD and to specific LXC profile

Hi,

I have deployed a Juju controller (no MAAS involved) and I have added a manual provisioned machine. Now I want to deploy a charm (vault p.e.) to LXC inside that machine but I need the IP address for the LXC instance has been assigned by the DCHP on the LAN, with same address space as the machine it hosts the LXC.

Machine   State    Address         Inst id                Series  AZ  Message
0         started  10.238.227.200  manual:10.238.227.200  jammy       Manually provisioned machine
0/lxd/10  started  10.121.203.110  juju-8c80d3-0-lxd-10   jammy       Container started

I have created a bridged interface on the host and declared a new profile inside LXC pointing to this bridge interface, but the LXC instance keeps with IP form lxdbr0 managed interface.

How can I tell juju to use the new created profile to have a DHCP assigned IP from same network as host has? I have tried model-config values, modifying default profile for LXC, etc. etc. with no luck.

Thanks in advance

There is not a way to tell juju which lxd profiles to use, outside of one in a charm. There are 2 work arounds for this. 1. Create a charm with the lxd profile for juju to use, it can be incredibly simple. 2. make changes to the default lxd profile for lxd configured on machine 0 in the example.

The second way doesn’t work, I have changed default profile inside the host and the LXC’s still getting an IP from managed network, don´t know why…

Can you instruct how to create or modify a charm with the lxd profile?

Thanks,

Hi, I’ve been able to download and unzip the charm, but I cannot find where I have to touch to let the charm deploy to specific LXD profile or network… :frowning:

Any help?

I have created a new LXD profile on host (machine 0) called bridged and br-ex as master interface:

# lxc profile list
+---------+------------------------------+---------+
|  NAME   |         DESCRIPTION          | USED BY |
+---------+------------------------------+---------+
| bridged | Bridged profile for DHCP LAN | 0       |
+---------+------------------------------+---------+
| default | Default LXD profile          | 0       |
+---------+------------------------------+---------+

In addition I have changed default profile to link to master interface br-ex too, as Heather has pointed for solution 2:

# lxc profile show default
config: {}
description: Default LXD profile
devices:
  eth0:
    nictype: bridged
    parent: br-ex
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by: []

As you can see both profiles are configured to use br-ex, instead of lxdbr0:

# lxc network list
+--------+----------+---------+-----------------+------+-------------+---------+---------+
|  NAME  |   TYPE   | MANAGED |      IPV4       | IPV6 | DESCRIPTION | USED BY |  STATE  |
+--------+----------+---------+-----------------+------+-------------+---------+---------+
| br-ex  | bridge   | NO      |                 |      |             | 2       |         |
+--------+----------+---------+-----------------+------+-------------+---------+---------+
| ens160 | physical | NO      |                 |      |             | 0       |         |
+--------+----------+---------+-----------------+------+-------------+---------+---------+
| lxdbr0 | bridge   | YES     | 10.121.203.1/24 | none |             | 0       | CREATED |
+--------+----------+---------+-----------------+------+-------------+---------+---------+

When I deploy a new charm to lxd a new LXC is created, with new virtual interface that has lxdbr0 as master, default profile (instead I have configured this profile with br-ex as master interface), and with no DHCP IP from LAN server:

# ip a
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP group default qlen 1000
    link/ether 00:50:56:bd:c3:7c brd ff:ff:ff:ff:ff:ff
    altname enp3s0
3: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether a2:7f:db:94:58:85 brd ff:ff:ff:ff:ff:ff
4: br-ex: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 00:50:56:bd:c3:7c brd ff:ff:ff:ff:ff:ff
    inet 10.238.227.200/24 brd 10.238.227.255 scope global br-ex
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:febd:c37c/64 scope link
       valid_lft forever preferred_lft forever
5: lxdbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d6:c1:7e:c0:7d:8f brd ff:ff:ff:ff:ff:ff
    inet 10.121.203.1/24 scope global lxdbr0
       valid_lft forever preferred_lft forever
19: veth4fce1978@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master lxdbr0 state UP group default qlen 1000
    link/ether 4e:d1:e7:ce:9a:66 brd ff:ff:ff:ff:ff:ff link-netnsid 0

# lxc profile show default
config: {}
description: Default LXD profile
devices:
  eth0:
    nictype: bridged
    parent: br-ex
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by:
- /1.0/instances/juju-8c80d3-0-lxd-13

Machine   State    Address         Inst id                Series  AZ  Message
0         started  10.238.227.200  manual:10.238.227.200  jammy       Manually provisioned machine
0/lxd/13  started  10.121.203.144  juju-8c80d3-0-lxd-13   jammy       Container started

Am I missing anything???