Skip to content

Commit

Permalink
docs(talos): add README for image customization
Browse files Browse the repository at this point in the history
Created `_packer/schematic.yaml` for defining image customization and `_packer/README.md` to guide on adding extensions to Talos images using the image factory.

Signed-off-by: Marcel Richter <[email protected]>
  • Loading branch information
mrclrchtr committed Mar 26, 2024
1 parent b3656ee commit e1beb5b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions _packer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hcloud.auto.pkrvars.hcl
26 changes: 26 additions & 0 deletions _packer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Add Extension to tho Talos Image

You can use the image factory to achieve this. The image factory is a tool that allows you to create custom Talos
images. You can find the documentation [here](https://www.talos.dev/v1.6/learn-more/image-factory/).

You can also use the endpoint to generate images. To achieve this, you need to adjust the `schematic.yaml` file to
include the extension you want to add to the image and then run the following command:

```shell
curl -X POST --data-binary @schematic.yaml https://factory.talos.dev/schematics
```

Then you can use the ID and the current Talos Version to get the image URLs with extensions:

- `https://factory.talos.dev/image/<ID>/<VERSION>/hcloud-amd64.raw.xz`.
- `https://factory.talos.dev/image/<ID>/<VERSION>/hcloud-arm64.raw.xz`.

Use these URLs in the `talos-hcloud.pkr.hcl` and replace `image_arm` and `image_x86` to create the snapshots with the
extensions.

You can create a file `hcloud.auto.pkrvars.hcl` to overwrite the default values. The file should look like this:
```hcl
talos_version = "v1.6.7"
image_url_arm = "https://factory.talos.dev/image/376567988ad370138ad8b2698212367b8edcb69b5fd68c80be1f2ec7d603b4ba/v1.6.7/hcloud-arm64.raw.xz"
image_url_x86 = "https://factory.talos.dev/image/376567988ad370138ad8b2698212367b8edcb69b5fd68c80be1f2ec7d603b4ba/v1.6.7/hcloud-amd64.raw.xz"
```
2 changes: 1 addition & 1 deletion _packer/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ if [[ -z "${HCLOUD_TOKEN:-}" ]]; then
export HCLOUD_TOKEN=$hcloud_token
fi
echo "Running packer build for talos-hcloud.pkr.hcl"
packer init talos-hcloud.pkr.hcl && packer build talos-hcloud.pkr.hcl
packer init . && packer build .
7 changes: 7 additions & 0 deletions _packer/schematic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is used to define the schematic configuration for image factory.
# The following extensions are required for longhorn for example.
customization:
systemExtensions:
officialExtensions:
- siderolabs/iscsi-tools
- siderolabs/util-linux-tools
14 changes: 12 additions & 2 deletions _packer/talos-hcloud.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ variable "talos_version" {
default = "v1.6.7"
}

variable "image_url_arm" {
type = string
default = null
}

variable "image_url_x86" {
type = string
default = null
}

variable "server_location" {
type = string
default = "fsn1"
}

locals {
image_arm = "https://github.com/siderolabs/talos/releases/download/${var.talos_version}/hcloud-arm64.raw.xz"
image_x86 = "https://github.com/siderolabs/talos/releases/download/${var.talos_version}/hcloud-amd64.raw.xz"
image_arm = var.image_url_arm != null ? var.image_url_arm : "https://github.com/siderolabs/talos/releases/download/${var.talos_version}/hcloud-arm64.raw.xz"
image_x86 = var.image_url_x86 != null ? var.image_url_x86 : "https://github.com/siderolabs/talos/releases/download/${var.talos_version}/hcloud-amd64.raw.xz"

# Add local variables for inline shell commands
download_image = "wget --timeout=5 --waitretry=5 --tries=5 --retry-connrefused --inet4-only -O /tmp/talos.raw.xz "
Expand Down

0 comments on commit e1beb5b

Please sign in to comment.