mirror of
https://github.com/apricote/flatcar-packer-hcloud.git
synced 2026-01-13 13:21:01 +00:00
No description
| .gitignore | ||
| butane-oem.yaml | ||
| flatcar.pkr.hcl | ||
| LICENSE | ||
| README.md | ||
Build Flatcar Snapshots on Hetzner Cloud with Packer
Important
This version of the README describes the process to build & test Hetzner OEM images using the Draft PR flatcar/scripts#1880. If you are a user looking to install Flatcar on Hetzner Cloud right now, you can check out the
mainbranch of this repo.
Requirements
Building Snapshots
In Hetzner Cloud, you can create a "Snapshot" of your server's disk. You can then use these snapshots to create new servers.
We will use Packer and the flatcar-install script to write the pre-built images from Flatcar CI to the disk and then create a snapshot.
$ git clone --branch oem-image-prebuilt https://github.com/apricote/flatcar-packer-hcloud.git
$ cd flatcar-packer-hcloud
$ export HCLOUD_TOKEN=<Your Hetzner Cloud API Token>
$ packer init .
# This will build the Snapshot for x86. You need to specify the path to your local image file.
$ packer build .
# ... Takes a few minutes
# It sometimes hangs on "==> hcloud.x86: + trap - EXIT", running with `PACKER_LOG=1` fixes it for me.
==> Builds finished. The artifacts of successful builds are:
--> hcloud.x86: A snapshot was created: 'flatcar-x86' (ID: 157132241)
--> hcloud.arm: A snapshot was created: 'flatcar-arm' (ID: 157132242)
$ hcloud image list --type=snapshot --selector=os=flatcar
ID TYPE NAME DESCRIPTION ARCHITECTURE IMAGE SIZE DISK SIZE CREATED DEPRECATED
157132241 snapshot - flatcar-x86 x86 0.47 GB 20 GB Sat Mar 30 16:48:22 CET 2024 -
157132242 snapshot - flatcar-arm arm 0.44 GB 20 GB Sat Mar 30 16:48:22 CET 2024 -
Create a Server
You can now create a new server from the snapshot. Not every feature might automatically work, as the snapshot is
missing the functionality from hc-utils. Configuring SSH Keys and User
Data (Ignition) will work as expected.
# Get ID of the most recent flatcar snapshot for x86
$ SNAPSHOT_ID=$(hcloud image list --type=snapshot --selector=os=flatcar --architecture=x86 -o=columns=id -o noheader --sort=created:desc | head -n1)
# Create a new server
# If you have, you can specify an Ignition config with `--user-data-from-file ignition-user.json`
$ hcloud server create --name flatcar-test --image $SNAPSHOT_ID --type cx11 --ssh-key <your-key>
# Wait about a minute or two for the server to be started
# Now you can login, the following is a helper that calls `ssh` with the public ipv4 address of the server
$ hcloud server ssh -u core flatcar-test