Skip to content

Commit 267d234

Browse files
committed
Introduce Slicer Platform docs section
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent 434cf04 commit 267d234

File tree

12 files changed

+812
-495
lines changed

12 files changed

+812
-495
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/.vscode
2+
/agent-skills
3+
/sdk

docs/getting-started/walkthrough.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
In this example we'll walk through how to create a Linux VM using Slicer on an x86_64 host, or an Arm64 host.
44

5-
The `/dev/kvm` device must exist and be available to continue.
6-
75
## Create the VM configuration
86

97
Slicer is a long lived process that can be run in the foreground or as a daemon with systemd.
@@ -141,4 +139,3 @@ slicer vm delete VM_NAME
141139
```
142140

143141
See all available commands with `slicer vm --help`, or refer to the [API reference](/reference/api) for direct HTTP access.
144-

docs/platform/custom-images.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Build a Custom Image
2+
3+
The default Slicer images ship with a minimal Ubuntu or Rocky Linux installation. If your sandboxes need specific packages - compilers, runtimes, libraries - installing them via userdata on every boot wastes time. A derived image bakes those dependencies in, so VMs start ready to work.
4+
5+
This page covers building a derived image locally. For publishing via CI, see [Publish your own images](/platform/publish-images/). For the full reference on image building, see [Build a custom root filesystem](/tasks/custom-image/).
6+
7+
## How it works
8+
9+
Slicer images are OCI images built with a Dockerfile. You write a `FROM` line pointing at a base Slicer image, add your `RUN` and `COPY` steps, then push the result to a container registry. Slicer pulls the image at startup and uses it for every VM in the host group.
10+
11+
The base images are listed in the [images reference](/reference/images/). For most x86_64 workloads:
12+
13+
```Dockerfile
14+
FROM ghcr.io/openfaasltd/slicer-systemd:6.1.90-x86_64-latest
15+
```
16+
17+
For arm64:
18+
19+
```Dockerfile
20+
FROM ghcr.io/openfaasltd/slicer-systemd-arm64:6.1.90-aarch64-latest
21+
```
22+
23+
## Example: Python sandbox
24+
25+
A sandbox image with Python 3, pip, and common data libraries pre-installed:
26+
27+
```Dockerfile
28+
FROM ghcr.io/openfaasltd/slicer-systemd:6.1.90-x86_64-latest
29+
30+
RUN apt-get update -qy \
31+
&& apt-get install -qy \
32+
python3 \
33+
python3-pip \
34+
python3-venv \
35+
&& apt-get clean
36+
```
37+
38+
Build and push:
39+
40+
```bash
41+
docker build -t ghcr.io/your-org/slicer-python:6.1.90-x86_64 .
42+
docker push ghcr.io/your-org/slicer-python:6.1.90-x86_64
43+
```
44+
45+
Then reference it in your Slicer YAML:
46+
47+
```yaml
48+
config:
49+
host_groups:
50+
- name: sandbox
51+
count: 0
52+
# ...
53+
image: "ghcr.io/your-org/slicer-python:6.1.90-x86_64"
54+
```
55+
56+
## Things to know about Dockerfile builds
57+
58+
Slicer images run systemd as PID 1. During the Docker build, systemd is not running, so:
59+
60+
* Use `systemctl enable SERVICE` to configure a service to start on boot. Do not use `--now`
61+
* Avoid commands that need a running kernel or network stack
62+
* Do not change the `CMD` or `ENTRYPOINT`. Slicer manages the boot process
63+
64+
For anything that cannot run inside a Dockerfile (e.g. commands that need networking or a running init system), use [userdata](/tasks/userdata/) to run the steps on first boot, or add a one-shot systemd unit.
65+
66+
See [Build a custom root filesystem](/tasks/custom-image/) for more detail.
67+
68+
## Watch the architecture
69+
70+
If you are building on a Mac with Apple Silicon, Docker defaults to arm64 images. A Slicer host running on x86_64 cannot boot an arm64 root filesystem, and the failure mode is not obvious. The VM may hang or kernel panic on boot.
71+
72+
Options:
73+
74+
* Use `docker buildx build --platform linux/amd64` to cross-compile locally. This works but is slower due to QEMU emulation inside Docker Desktop.
75+
* Build on a matching architecture: an x86_64 Linux machine, a CI runner, or a Slicer VM itself.
76+
77+
If all your Slicer hosts are arm64 (e.g. Raspberry Pi, Ampere), the reverse applies - build for `linux/arm64`.
78+
79+
Slicer images are not multi-arch. Each architecture needs its own image built natively on matching hardware. If you need to automate this, see [Publish your own images](/platform/publish-images/).
80+
81+
!!! note "Private registries"
82+
GHCR packages default to private. Either make the package public in GitHub's package settings, or configure `insecure_registry: true` in your Slicer YAML if using a private registry without TLS.
83+
84+
## Test the image
85+
86+
After pushing, restart Slicer with the new image reference and create a sandbox:
87+
88+
```bash
89+
slicer new sandbox \
90+
--count=0 \
91+
> sandbox.yaml
92+
```
93+
94+
Edit `sandbox.yaml` and set the `image:` field to your custom image, then start Slicer:
95+
96+
```bash
97+
sudo slicer up ./sandbox.yaml
98+
```
99+
100+
Create a VM and verify the packages are present:
101+
102+
```bash
103+
export TOKEN=$(sudo cat /var/lib/slicer/auth/token)
104+
105+
curl -sf -H "Authorization: Bearer $TOKEN" \
106+
-H "Content-Type: application/json" \
107+
-X POST http://127.0.0.1:8080/hostgroup/sandbox/nodes -d '{}'
108+
109+
# Wait for agent, then check python is installed
110+
curl -sf -H "Authorization: Bearer $TOKEN" \
111+
-X POST \
112+
"http://127.0.0.1:8080/vm/sandbox-1/exec?cmd=python3&args=--version&stdout=true"
113+
```
114+
115+
## Wrapping up
116+
117+
Derived images let you trade a one-time build step for faster, more predictable sandbox boot times. Bake in everything your workload needs, publish it to GHCR, and let Slicer pull it on startup.
118+
119+
See also:
120+
121+
* [Build a custom root filesystem](/tasks/custom-image/) - full reference for Dockerfile-based image builds
122+
* [Images for microVMs](/reference/images/) - base image tags and availability
123+
* [Userdata](/tasks/userdata/) - run scripts on first boot for anything that cannot be baked into the image
124+
* [Storage backends](/storage/overview/) - ZFS and devmapper for near-instant boot from snapshots
Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Run a task in a VM
1+
# Ephemeral Tasks
22

3-
This example shows how to run a one-shot task in a VM via API. The CLI can also act as a client to the API during testing.
3+
This page shows how to launch short-lived VMs for one-shot tasks via the API. The CLI can also act as a client to the API during testing.
44

55
Use-cases could include:
66

@@ -143,50 +143,3 @@ After SSH is disabled, the only way to debug a machine is via the Slicer agent u
143143
You can also disable `slicer-agent` (not actually a full SSH daemon), however the `slicer vm` commands will no longer work.
144144

145145
If you publish an image to the Docker Hub, make sure you include its prefix i.e. `docker.io/owner/repo:tag`.
146-
147-
### Cache the Kernel to a local file
148-
149-
Rather than downloading an extracting the Kernel on each run of Slicer, you can extract a given vmlinux file and tell the YAML file to use that.
150-
151-
This is preferred for a long-running host, where we need to keep the root-filesystem image and Kernel in sync.
152-
153-
The Kernel must agree with the root filesystem image, which means using a proper tag and not a `latest` tag.
154-
155-
Why? The Kernel is built as a vmlinux, however its modules are packaged into the root filesystem image.
156-
157-
Run the following:
158-
159-
```bash
160-
$ arkade get crane
161-
$ crane ls ghcr.io/openfaasltd/actuated-kernel:5.10.240-x86_64-latest
162-
163-
5.10.240-x86_64-3d7a67d1683b524b4128ad338f90b1da710f2fd9
164-
5.10.240-kvm-x86_64-3d7a67d1683b524b4128ad338f90b1da710f2fd9
165-
5.10.240-x86_64-ea04b63b9117c966a57e17e1bc1bfcf713cd6276
166-
5.10.240-x86_64-bb71bdd1cd06bad2cc11f8ab3f323c3f19d41c8b
167-
5.10.240-x86_64-2f2ebc0bbefe128aa3061e6ea6806cbcdc975208
168-
6.1.90-aarch64-2f2ebc0bbefe128aa3061e6ea6806cbcdc975208
169-
6.1.90-aarch64-5c59e9b9b08eea49499be8449099291c93469b80
170-
5.10.240-x86_64-5c59e9b9b08eea49499be8449099291c93469b80
171-
```
172-
173-
Pick a stable tag for your architecture i.e. `x86_64-SHA` or `aarch64-SHA`, then run:
174-
175-
```bash
176-
$ arkade oci install ghcr.io/openfaasltd/actuated-kernel:5.10.240-x86_64-2f2ebc0bbefe128aa3061e6ea6806cbcdc975208 --output ./
177-
$ ls
178-
vmlinux
179-
```
180-
181-
Next, find the matching root filesystem image:
182-
183-
```bash
184-
$ crane ls ghcr.io/openfaasltd/slicer-systemd
185-
```
186-
187-
Use it in your YAML file, replacing `kernel_image` with `kernel_file`:
188-
189-
```yaml
190-
kernel_file: "./vmlinux"
191-
image: "ghcr.io/openfaasltd/slicer-systemd:5.10.240-x86_64-2f2ebc0bbefe128aa3061e6ea6806cbcdc975208"
192-
```

0 commit comments

Comments
 (0)