Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cloud-init to enable lxd-agent on Ubuntu releases before 20.04 #12680

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ hotplug
hotplugged
hotplugging
HTTPS
HWE
ICMP
IPAM
idmap
Expand Down
1 change: 1 addition & 0 deletions doc/cloud-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Rebooting the instance does not re-trigger the actions.
To use `cloud-init`, you must base your instance on an image that has `cloud-init` installed:

* All images from the `ubuntu` and `ubuntu-daily` {ref}`image servers <remote-image-servers>` have `cloud-init` support.
However, images for Ubuntu releases prior to `20.04` require special handling to integrate properly with `cloud-init`, so that `lxc exec` works correctly with virtual machines that use those images. Refer to {ref}`vm-cloud-init-config`.
* Images from the [`images` remote](https://images.linuxcontainers.org/) have `cloud-init`-enabled variants, which are usually bigger in size than the default variant.
The cloud variants use the `/cloud` suffix, for example, `images:ubuntu/22.04/cloud`.

Expand Down
21 changes: 21 additions & 0 deletions doc/reference/devices_disk.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ISO file

lxc config device add <instance_name> <device_name> disk source=<file_path_on_host>

(vm-cloud-init-config)=
VM `cloud-init`
: You can generate a `cloud-init` configuration ISO from the {config:option}`instance-cloud-init:cloud-init.vendor-data` and {config:option}`instance-cloud-init:cloud-init.user-data` configuration keys and attach it to a virtual machine.
The `cloud-init` that is running inside the VM then detects the drive on boot and applies the configuration.
Expand All @@ -70,6 +71,26 @@ VM `cloud-init`

lxc config device add <instance_name> <device_name> disk source=cloud-init:config

Adding such a configuration disk might be needed if the VM image that is used includes `cloud-init` but not the `lxd-agent`. This is the case for official Ubuntu images prior to `20.04`. On such images, the following steps enable the LXD agent and thus provide the ability to use `lxc exec` to access the VM:

lxc init ubuntu-daily:18.04 --vm u1
lxc config device add u1 config disk source=cloud-init:config
lxc config set u1 cloud-init.user-data - << EOF
#cloud-config
#packages:
# - linux-image-virtual-hwe-16.04 # 16.04 GA kernel as a problem with vsock
runcmd:
- mount -t 9p config /mnt
- cd /mnt
- ./install.sh
- cd /
- umount /mnt
- systemctl start lxd-agent # XXX: causes a reboot
EOF
lxc start --console u1

Note that for `16.04`, the HWE kernel is required to work around a problem with `vsock` (see the commented out section in the above `cloud-config`).

(devices-disk-initial-config)=
## Initial volume configuration for instance root disk devices

Expand Down
1 change: 0 additions & 1 deletion lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,6 @@ cp udev/99-lxd-agent.rules /lib/udev/rules.d/
cp systemd/lxd-agent.service /lib/systemd/system/
cp systemd/lxd-agent-setup /lib/systemd/
systemctl daemon-reload
systemctl enable lxd-agent.service

echo ""
echo "LXD agent has been installed, reboot to confirm setup."
Expand Down