Skip to content

Commit

Permalink
Examples update (#927)
Browse files Browse the repository at this point in the history
* Start work of making Fedora CoreOS example out of the old CoreOS one

* Update mounting for QEMU agent to use /var since /mnt is a synlink in
fcos

* Bump version of dmacvicar/libvirt to latest

* Switch ignition provider to get configspec Fedora CoreOS wants
Removed no longer required filesystem line

* Update README to refelct only one tested arch
Update to refelct CoreOS name change
  • Loading branch information
shafer authored Mar 21, 2024
1 parent a9d9618 commit 632fc50
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
# CoreOS multi-machine example setup
# Fedora CoreOS multi-machine example setup

### Requirements
* Linux Kernel ~> 4.14
* Libvirt ~> 3.0
* QEMU ~> 2.6

This is a relatively simple scalable example using CoreOS as operating system.
By modifying the `hosts` variable you can kickstart any number of virtual machines
This is a relatively simple scalable example using Fedroa CoreOS as operating system.
By modifying the `hosts` variable you can start any number of virtual machines
with their own Ignition configuration


### Supported architectures
This example will work on i686 (x86), x86\_64 (AMD64), aarch64 (ARM64), s390x (IBM Z) and IBM PowerPC. On i686, x86\_64, and aarch64, the Terraform provider uses QEMU's firmware configuration (fw\_cfg) device to pass the Ignition config through to the Ignition instance running in the virtual machine. In order for this to work, Ignition needs to be run with `--provider=qemu`. Unfortunately, QEMU doesn't support the firmware configuration device for s390x and PowerPC guests, so alternatively, a virtio-blk device is created with a serial of `ignition` which ignition detects and reads.
This example will work on x86\_64 (AMD64). The Terraform provider uses QEMU's firmware configuration (fw\_cfg) device to pass the Ignition config through to the Ignition instance running in the virtual machine. In order for this to work, Ignition needs to be run with `--provider=qemu`.


### Using the QEMU Guest Agent

In case you don't use the networks provided by libvirt you may run into the issue that you won't be able to receive the IP addresses from the VM you create.

Using the QEMU guest agent allows libvirt to pick up the address by hooking itself into the guest operating system.
As CoreOS comes without any guest agents we need to supply it from somewhere.
As Fedora CoreOS comes without any guest agents we need to supply it from somewhere.
If the machine has internet access you can edit the `qemu-agent.service` file and remove the `ExecStartPre` line and the docker daemon should download the appropriate container when you activate the service file in the Ignition config. If the machine has no access to the internet we need to upload the container from the KVM host.[1]
```bash
$ docker pull docker.io/rancher/os-qemuguestagent:v2.8.1-2
$ docker save docker.io/rancher/os-qemuguestagent:v2.8.1-2 -o /srv/images/qemu-guest-agent.tar
```

Make sure the relevant blocks are uncommented in the domain definition and the Ignition config. The Ignition configuration should include the two additional files `docker-images.mount` and `qemu-agent.service`. Note that the`qemu-guest-agent.tar` needs to be local to the KVM host and not the machine running terraform.
Make sure the relevant blocks are uncommented in the domain definition and the Ignition config. The Ignition configuration should include the two additional files `docker-images.mount` and `qemu-agent.service`. Note that the`qemu-guest-agent.tar` needs to be local to the KVM host and not the machine running terraform. Also the /srv/images directory needs to be readable by whatever user your qemu process runs as.


### Known Bugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ data "ignition_config" "startup" {

# Replace the default hostname with our generated one
data "ignition_file" "hostname" {
filesystem = "root" # default `ROOT` filesystem
path = "/etc/hostname"
mode = 420 # decimal 0644

Expand All @@ -44,7 +43,7 @@ data "ignition_user" "core" {

## Relevant for the QEMU Guest Agent example
#data "ignition_systemd_unit" "mount-images" {
# name = "mnt-images.mount"
# name = "var-mnt-images.mount"
# enabled = true
# content = "${file("${path.module}/qemu-agent/docker-images.mount")}"
#}
Expand Down
4 changes: 2 additions & 2 deletions examples/v0.13/coreos/main.tf → examples/v0.13/fcos/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.2"
version = "0.6.12"
}
ignition = {
source = "terraform-providers/ignition"
source = "community-terraform-providers/ignition"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Before=local-fs.target
[Mount]
What=qemu_docker_images
Where=/mnt/images
Where=/var/mnt/images
Options=ro,trans=virtio,version=9p2000.L
Type=9p
[Install]
Expand Down
File renamed without changes.

0 comments on commit 632fc50

Please sign in to comment.