Example: Run a KVM guest¶
It is possible to launch a Virtual Machine (VM) within a GitHub Action. Support for virtualization is not enabled by default for Actuated. The Agent has to be configured to use a custom kernel.
There are some prerequisites to enable KVM support:
aarch64
runners are not supported at the moment.- A bare-metal host for the Agent is required.
Nested virtualisation is a premium feature
This feature requires a plan size of 15 concurrent builds or greater, however you can get a 14-day free trial by contacting our team directly through the actuated Slack.
Configure the Agent¶
-
Make sure nested virtualization is enabled on the Agent host.
-
Edit
/etc/default/actuated
on the Actuated Agent and add thekvm
suffix to theAGENT_KERNEL_REF
variable:- AGENT_KERNEL_REF="ghcr.io/openfaasltd/actuated-kernel:x86_64-latest" + AGENT_KERNEL_REF="ghcr.io/openfaasltd/actuated-kernel:x86_64-kvm-latest"
-
Also add it to the
AGENT_IMAGE_REF
line:- AGENT_IMAGE_REF="ghcr.io/openfaasltd/actuated-ubuntu22.04:x86_64-latest" + AGENT_IMAGE_REF="ghcr.io/openfaasltd/actuated-ubuntu22.04:x86_64-kvm-latest"
-
Restart the Agent to use the new kernel.
sudo systemctl daemon-reload && \ sudo systemctl restart actuated
-
Run a test build to verify KVM support is enabled in the runner. The specs script from the test build will report whether
/dev/kvm
is available.
Run a Firecracker microVM¶
This example is an adaptation of the Firecracker quickstart guide that we run from within a GitHub Actions workflow.
The workflow instals Firecracker, configures and boots a guest VM and then waits 20 seconds before shutting down the VM and exiting the workflow.
-
Create a new repository and add a workflow file.
The workflow file:
./.github/workflows/vm-run.yaml
:name: vm-run on: push jobs: vm-run: runs-on: actuated-4cpu-8gb steps: - uses: actions/checkout@master with: fetch-depth: 1 - name: Install arkade uses: alexellis/setup-arkade@v2 - name: Install firecracker run: sudo arkade system install firecracker - name: Run microVM run: sudo ./run-vm.sh
-
Add the
run-vm.sh
script to the root of the repository.Running the script will:
- Get the kernel and rootfs for the microVM
- Start fireckracker and configure the guest kernel and rootfs
- Start the guest machine
- Wait for 20 seconds and kill the firecracker process so workflow finishes.
The
run-vm.sh
script:#!/bin/bash # Clone the example repo git clone https://github.com/skatolo/nested-firecracker.git # Run the VM script ./nested-firecracker/run-vm.sh
-
Hit commit and check the run logs of the workflow. You should find the login prompt of the running microVM in the logs.
The full example is available on GitHub
For more examples and use-cases see: