I’m struggling new key of cloud-in “cloud-init.network-config” which was supported in 4.21.
I was just going through cloud-init - LXD documentation to setup static IP address by cloud-init, but still no luck.
What is I’m wrong or missing here?
Here is LXD version and default profile, described what I did step by step.
# lxd --version 4.21 # lxc profile show default config: {} description: Default LXD profile devices: eth0: name: eth0 network: lxdbr0 type: nic eth1: name: eth1 nictype: bridged parent: br0 type: nic root: path: / pool: default type: disk name: default used_by: []
Create new container with ubuntu20.04 image and apply custom network configuration with cloud-init.
# lxc init ubuntu:20.04 c0 # cat c0-network.yaml version: 1 config: - type: physical name: eth0 subnets: - type: static ipv4: true address: 192.168.244.20/24 netmask: 255.255.255.0 gateway: 192.168.244.1 control: auto - type: nameserver address: 10.128.8.22 # cat c0-network.yaml | lxc config set c0 cloud-init.network-config -
Applied configuration seems to be OK below.
# lxc config show c0 architecture: x86_64 config: cloud-init.network-config: | version: 1 config: - type: physical name: eth0 subnets: - type: static ipv4: true address: 192.168.244.20/24 netmask: 255.255.255.0 gateway: 192.168.244.1 control: auto - type: nameserver address: 10.128.8.22 image.architecture: amd64 image.description: ubuntu 20.04 LTS amd64 (release) (20211129) image.label: release image.os: ubuntu image.release: focal image.serial: "20211129" image.type: squashfs image.version: "20.04" volatile.apply_template: create volatile.base_image: a8402324842148ccfcbacbc69bf251baa9703916593089f0609e8d45e3185bff volatile.eth0.hwaddr: 00:16:3e:43:d2:94 volatile.eth1.hwaddr: 00:16:3e:f0:4c:06 volatile.idmap.base: "0" volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]' volatile.last_state.idmap: '[]' volatile.uuid: 13505685-2c2d-4571-9116-aab53f8bfaf5 devices: {} ephemeral: false profiles: - default stateful: false description: ""
Then start container, however cloud-init I set was not applied.
# lxc start c0 # lxc list +------+---------+------------------------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+---------+------------------------+------+-----------+-----------+ | c0 | RUNNING | 192.168.244.202 (eth0) | | CONTAINER | 0 | +------+---------+------------------------+------+-----------+-----------+ # lxc exec c0 cat /etc/netplan/50-cloud-init.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: version: 2 ethernets: eth0: dhcp4: true
Anything missing and wrong?