Skip to content

Commit 3db826f

Browse files
committed
doc: update quickstart guide to download latest artifacts
We need to manually change what versions our quick start guide points to at every release. To avoid it getting behind, this change adds automatic detection of the CI artifacts related to the lastest version (which was already automatically detected). This means that CI artifacts will not point to the latest available but they will be the same we use to test the latest release, to ensure compatibility and that the guide always works. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 888c5f3 commit 3db826f

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

docs/getting-started.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,44 @@ For simplicity, this guide will not use the [`jailer`](../src/jailer/).
9494
### Getting a rootfs and Guest Kernel Image
9595

9696
To successfully start a microVM, you will need an uncompressed Linux kernel
97-
binary, and an ext4 file system image (to use as rootfs). This guide uses a 5.10
98-
kernel image with a Ubuntu 24.04 rootfs from our CI:
97+
binary, and an ext4 file system image (to use as rootfs). This guide uses the
98+
latest kernel image and Ubuntu rootfs available in our CI for the latest
99+
release.
99100

100101
```bash
101102
ARCH="$(uname -m)"
102-
103-
latest=$(wget "http://spec.ccfc.min.s3.amazonaws.com/?prefix=firecracker-ci/v1.11/$ARCH/vmlinux-5.10&list-type=2" -O - 2>/dev/null | grep -oP "(?<=<Key>)(firecracker-ci/v1.11/$ARCH/vmlinux-5\.10\.[0-9]{1,3})(?=</Key>)")
103+
release_url="https://github.com/firecracker-microvm/firecracker/releases"
104+
latest_version=$(basename $(curl -fsSLI -o /dev/null -w %{url_effective} ${release_url}/latest))
105+
CI_VERSION=${latest_version%.*}
106+
latest_kernel_key=$(curl "http://spec.ccfc.min.s3.amazonaws.com/?prefix=firecracker-ci/$CI_VERSION/$ARCH/vmlinux-&list-type=2" \
107+
| grep -oP "(?<=<Key>)(firecracker-ci/$CI_VERSION/$ARCH/vmlinux-[0-9]+\.[0-9]+\.[0-9]{1,3})(?=</Key>)" \
108+
| sort -V | tail -1)
104109

105110
# Download a linux kernel binary
106-
wget "https://s3.amazonaws.com/spec.ccfc.min/${latest}"
111+
wget "https://s3.amazonaws.com/spec.ccfc.min/${latest_kernel_key}"
112+
113+
latest_ubuntu_key=$(curl "http://spec.ccfc.min.s3.amazonaws.com/?prefix=firecracker-ci/$CI_VERSION/$ARCH/ubuntu-&list-type=2" \
114+
| grep -oP "(?<=<Key>)(firecracker-ci/$CI_VERSION/$ARCH/ubuntu-[0-9]+\.[0-9]+\.squashfs)(?=</Key>)" \
115+
| sort -V | tail -1)
116+
ubuntu_version=$(basename $latest_ubuntu_key .sqashfs | grep -oE '[0-9]+\.[0-9]+')
107117

108118
# Download a rootfs
109-
wget -O ubuntu-24.04.squashfs.upstream "https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/v1.11/${ARCH}/ubuntu-24.04.squashfs"
119+
wget -O ubuntu-$ubuntu_version.squashfs.upstream "https://s3.amazonaws.com/spec.ccfc.min/$latest_ubuntu_key"
110120

111121
# Create an ssh key for the rootfs
112-
unsquashfs ubuntu-24.04.squashfs.upstream
122+
unsquashfs ubuntu-$ubuntu_version.squashfs.upstream
113123
ssh-keygen -f id_rsa -N ""
114124
cp -v id_rsa.pub squashfs-root/root/.ssh/authorized_keys
115-
mv -v id_rsa ./ubuntu-24.04.id_rsa
125+
mv -v id_rsa ./ubuntu-$ubuntu_version.id_rsa
116126
# create ext4 filesystem image
117127
sudo chown -R root:root squashfs-root
118-
truncate -s 400M ubuntu-24.04.ext4
119-
sudo mkfs.ext4 -d squashfs-root -F ubuntu-24.04.ext4
128+
truncate -s 400M ubuntu-$ubuntu_version.ext4
129+
sudo mkfs.ext4 -d squashfs-root -F ubuntu-$ubuntu_version.ext4
130+
131+
# Verify everything was correctly set up and print versions
132+
echo "Kernel: $(ls vmlinux-* | tail -1)"
133+
echo "Rootfs: $(ls *.ext4 | tail -1)"
134+
echo "SSH Key: $(ls *.id_rsa | tail -1)"
120135
```
121136

122137
### Getting a Firecracker Binary
@@ -241,7 +256,7 @@ sudo curl -X PUT --unix-socket "${API_SOCKET}" \
241256
}" \
242257
"http://localhost/boot-source"
243258

244-
ROOTFS="./ubuntu-24.04.ext4"
259+
ROOTFS="./$(ls *.ext4 | tail -1)"
245260

246261
# Set rootfs
247262
sudo curl -X PUT --unix-socket "${API_SOCKET}" \
@@ -282,14 +297,16 @@ sudo curl -X PUT --unix-socket "${API_SOCKET}" \
282297
# started before we attempt to SSH into it.
283298
sleep 2s
284299

300+
KEY_NAME=./$(ls *.id_rsa | tail -1)
301+
285302
# Setup internet access in the guest
286-
ssh -i ./ubuntu-24.04.id_rsa [email protected] "ip route add default via 172.16.0.1 dev eth0"
303+
ssh -i $KEY_NAME [email protected] "ip route add default via 172.16.0.1 dev eth0"
287304

288305
# Setup DNS resolution in the guest
289-
ssh -i ./ubuntu-24.04.id_rsa [email protected] "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
306+
ssh -i $KEY_NAME [email protected] "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
290307

291308
# SSH into the microVM
292-
ssh -i ./ubuntu-24.04.id_rsa [email protected]
309+
ssh -i $KEY_NAME [email protected]
293310

294311
# Use `root` for both the login and password.
295312
# Run `reboot` to exit.

0 commit comments

Comments
 (0)