Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Flatcar Linux examples and use Ignition #980

Merged
merged 1 commit into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Download a recent Fedora CoreOS or Flatcar Linux release.

```
$ ./scripts/get-fedora-coreos stable 36.20220618.3.1 .
$ ./scripts/get-flatcar stable 2605.6.0 .
$ ./scripts/get-flatcar stable 3227.2.0 .
```

Move the images to `/var/lib/matchbox/assets`,
Expand All @@ -260,7 +260,7 @@ Move the images to `/var/lib/matchbox/assets`,
├── fedora-coreos-36.20220618.3.1-live-rootfs.x86_64.img

/var/lib/matchbox/assets/flatcar/
└── 2605.6.0
└── 3227.2.0
├── Flatcar_Image_Signing_Key.asc
├── flatcar_production_image.bin.bz2
├── flatcar_production_image.bin.bz2.sig
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Download Fedora CoreOS or Flatcar Linux image assets to `examples/assets`.

```sh
$ ./scripts/get-fedora-coreos stable 36.20220618.3.1 ./examples/assets
$ ./scripts/get-flatcar stable 2605.6.0 ./examples/assets
$ ./scripts/get-flatcar stable 3227.2.0 ./examples/assets
```

For development convenience, add `/etc/hosts` entries for nodes so they may be referenced by name.
Expand Down
37 changes: 19 additions & 18 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,37 @@ These examples mount raw Matchbox objects into a Matchbox server's `/var/lib/mat
| flatcar | Flatcar Linux live PXE | RAM | [docs](https://docs.flatcar-linux.org/os/booting-with-ipxe/) |
| flatcar-install | Flatcar Linux install | Disk | [docs](https://docs.flatcar-linux.org/os/booting-with-ipxe/) |

### Customization
### SSH Access

For Fedora CoreOS, add an SSH authorized key to Fedora CoreOS Config (`ignition/fedora-coreos.yaml`) and regenerate the Ignition Config.
For Fedora CoreOS, add an SSH authorized key to the Butane Config (`ignition/fedora-coreos.yaml`) and regenerate the Ignition Config.

```yaml
variant: fcos
version: 1.1.0
version: 1.4.0
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa pub-key-goes-here
- ssh-ed25519 SET_PUBKEY_HERE
```

```
podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < fedora-coreos.yaml > fedora-coreos.ign
```

For Flatcar Linux, add a Matchbox variable to a Group (`groups/flatcar-install/flatcar.json`) to set the SSH authorized key (or directly update the Container Linux Config).

```json
{
"id": "stage-1",
"name": "Flatcar Linux",
"profile": "flatcar",
"selector": {
"os": "installed"
},
"metadata": {
"ssh_authorized_keys": ["ssh-rsa pub-key-goes-here"]
}
}
For Flatcar Linux, add an SSH authorized key to the Butane config (`ignition/flatcar.yaml` or `ignition/flatcar-install.yaml`) and regenerate the Ignition Config.

```yaml
variant: flatcar
version: 1.0.0
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-ed25519 SET_PUBKEY_HERE
```

```
podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < flatcar.yaml > flatcar.ign
podman run -i --rm quay.io/coreos/fcct:release --pretty --strict < flatcar-install.yaml > flatcar-install.ign
```
3 changes: 1 addition & 2 deletions examples/groups/flatcar-install/flatcar.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
"selector": {
"os": "installed"
},
"metadata": {
}
"metadata": {}
}
7 changes: 1 addition & 6 deletions examples/groups/flatcar-install/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
"id": "stage-0",
"name": "Flatcar Linux install",
"profile": "flatcar-install",
"metadata": {
"os_channel": "stable",
"os_version": "2605.6.0",
"ignition_endpoint": "http://matchbox.example.com:8080/ignition",
"baseurl": "http://matchbox.example.com:8080/assets/flatcar"
}
"metadata": {}
}
36 changes: 36 additions & 0 deletions examples/ignition/flatcar-install.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"ignition": {
"version": "3.3.0"
},
"passwd": {
"users": [
{
"name": "core",
"sshAuthorizedKeys": [
"ssh-ed25519 SET_PUBKEY_HERE"
]
}
]
},
"storage": {
"files": [
{
"path": "/opt/installer",
"contents": {
"compression": "gzip",
"source": "data:;base64,H4sIAAAAAAAC/4SOsU4DMRBEe3/FEmrbx1EQRUIU/AMVzdrecEZrb+TdnC5/T3GhoaF8mhnNe3yIqfaYUBfwtLl8HQzeD7Jxg6cJvD9jZTgsZpdTjA0tL0m2QBu2C1PI0k7H6TjF+tWrVelvoq+1qyEzlQN4gd8kfKt0d2a0jMPfO/DpAHyBWGiNa8Gd30ENE9NOH/A8zy9hDtPOCf61QVUyjfezfVb/mFwLrVgaKJkxOb2pUcvGMCiJmPsJAAD//1GtasgbAQAA"
},
"mode": 320
}
]
},
"systemd": {
"units": [
{
"contents": "[Unit]\nRequires=network-online.target\nAfter=network-online.target\n[Service]\nType=simple\nExecStart=/opt/installer\n[Install]\nWantedBy=multi-user.target\n",
"enabled": true,
"name": "installer.service"
}
]
}
}
22 changes: 9 additions & 13 deletions examples/ignition/flatcar-install.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
variant: flatcar
version: 1.0.0
systemd:
units:
- name: installer.service
enable: true
enabled: true
contents: |
[Unit]
Requires=network-online.target
Expand All @@ -15,28 +17,22 @@ systemd:
storage:
files:
- path: /opt/installer
filesystem: root
mode: 0500
contents:
inline: |
#!/bin/bash -ex
curl --retry 10 --fail "{{.ignition_endpoint}}?{{.request.raw_query}}&os=installed" -o ignition.json
curl --retry 10 --fail "http://matchbox.example.com:8080/ignition?os=installed" -o ignition.json
flatcar-install \
-d /dev/sda \
-C {{.os_channel}} \
-V {{.os_version}} \
{{- if index . "baseurl"}}-b {{.baseurl}} \{{end}}
-d /dev/vda \
-C stable \
-V 3227.2.0 \
-b http://matchbox.example.com:8080/assets/flatcar \
-i ignition.json
udevadm settle
systemctl reboot

{{ if index . "ssh_authorized_keys" }}
passwd:
users:
- name: core
ssh_authorized_keys:
{{ range $element := .ssh_authorized_keys }}
- {{$element}}
{{end}}
{{end}}

- ssh-ed25519 SET_PUBKEY_HERE
15 changes: 15 additions & 0 deletions examples/ignition/flatcar.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ignition": {
"version": "3.3.0"
},
"passwd": {
"users": [
{
"name": "core",
"sshAuthorizedKeys": [
"ssh-ed25519 SET_PUBKEY_HERE"
]
}
]
}
}
9 changes: 3 additions & 6 deletions examples/ignition/flatcar.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
{{ if index . "ssh_authorized_keys" }}
variant: flatcar
version: 1.0.0
passwd:
users:
- name: core
ssh_authorized_keys:
{{ range $element := .ssh_authorized_keys }}
- {{$element}}
{{end}}
{{end}}
- ssh-ed25519 SET_PUBKEY_HERE
8 changes: 3 additions & 5 deletions examples/profiles/flatcar-install.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"id": "flatcar-install",
"name": "Flatcar Linux install to disk",
"boot": {
"kernel": "/assets/flatcar/2605.6.0/flatcar_production_pxe.vmlinuz",
"kernel": "/assets/flatcar/3227.2.0/flatcar_production_pxe.vmlinuz",
"initrd": [
"/assets/flatcar/2605.6.0/flatcar_production_pxe_image.cpio.gz"
"/assets/flatcar/3227.2.0/flatcar_production_pxe_image.cpio.gz"
],
"args": [
"initrd=flatcar_production_pxe_image.cpio.gz",
"flatcar.config.url=http://matchbox.example.com:8080/ignition?uuid=${uuid}&mac=${mac:hexhyp}",
"flatcar.first_boot=yes",
"console=tty0",
"console=ttyS0",
"flatcar.autologin"
]
},
"ignition_id": "flatcar-install.yaml"
"ignition_id": "flatcar-install.ign"
}
8 changes: 3 additions & 5 deletions examples/profiles/flatcar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"id": "flatcar",
"name": "Flatcar Linux",
"boot": {
"kernel": "/assets/flatcar/2605.6.0/flatcar_production_pxe.vmlinuz",
"kernel": "/assets/flatcar/3227.2.0/flatcar_production_pxe.vmlinuz",
"initrd": [
"/assets/flatcar/2605.6.0/flatcar_production_pxe_image.cpio.gz"
"/assets/flatcar/3227.2.0/flatcar_production_pxe_image.cpio.gz"
],
"args": [
"initrd=flatcar_production_pxe_image.cpio.gz",
"flatcar.config.url=http://matchbox.example.com:8080/ignition?uuid=${uuid}&mac=${mac:hexhyp}",
"flatcar.first_boot=yes",
"console=tty0",
"console=ttyS0",
"flatcar.autologin"
]
},
"ignition_id": "flatcar.yaml"
"ignition_id": "flatcar.ign"
}
8 changes: 4 additions & 4 deletions examples/terraform/fedora-coreos-install/profiles.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Fedora CoreOS profile
resource "matchbox_profile" "fedora-coreos-install" {
name = "worker"
kernel = "https://builds.coreos.fedoraproject.org/prod/streams/${var.os_stream}/builds/${var.os_version}/x86_64/fedora-coreos-${var.os_version}-live-kernel-x86_64"
kernel = "/assets/fedora-coreos/fedora-coreos-${var.os_version}-live-kernel-x86_64"
initrd = [
"--name main https://builds.coreos.fedoraproject.org/prod/streams/${var.os_stream}/builds/${var.os_version}/x86_64/fedora-coreos-${var.os_version}-live-initramfs.x86_64.img"
"--name main /assets/fedora-coreos/fedora-coreos-${var.os_version}-live-initramfs.x86_64.img"
]

args = [
"initrd=main",
"coreos.live.rootfs_url=https://builds.coreos.fedoraproject.org/prod/streams/${var.os_stream}/builds/${var.os_version}/x86_64/fedora-coreos-${var.os_version}-live-rootfs.x86_64.img",
"coreos.inst.install_dev=/dev/sda",
"coreos.live.rootfs_url=${var.matchbox_http_endpoint}/assets/fedora-coreos/fedora-coreos-${var.os_version}-live-rootfs.x86_64.img",
"coreos.inst.install_dev=/dev/vda",
"coreos.inst.ignition_url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
]

Expand Down
2 changes: 1 addition & 1 deletion examples/terraform/fedora-coreos-install/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ terraform {
required_providers {
ct = {
source = "poseidon/ct"
version = "0.10.0"
version = "0.11.0"
}
matchbox = {
source = "poseidon/matchbox"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
variant: flatcar
version: 1.0.0
systemd:
units:
- name: installer.service
enable: true
enabled: true
contents: |
[Unit]
Requires=network-online.target
Expand All @@ -15,22 +17,19 @@ systemd:
storage:
files:
- path: /opt/installer
filesystem: root
mode: 0500
contents:
inline: |
#!/bin/bash -ex
curl --retry 10 "{{.ignition_endpoint}}?{{.request.raw_query}}&os=installed" -o ignition.json
curl --retry 10 "${matchbox_http_endpoint}/ignition?os=installed" -o ignition.json
flatcar-install \
-d /dev/sda \
-C stable \
-V current \
{{- if index . "baseurl"}}-b {{.baseurl}} \{{end}}
-d /dev/vda \
-b ${matchbox_http_endpoint}/assets/flatcar \
-i ignition.json
udevadm settle
systemctl reboot
passwd:
users:
- name: core
ssh_authorized_keys:
- {{.ssh_authorized_key}}
- ${ssh_authorized_key}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
variant: flatcar
version: 1.0.0
passwd:
users:
- name: core
ssh_authorized_keys:
- {{.ssh_authorized_key}}
- ${ssh_authorized_key}
16 changes: 3 additions & 13 deletions examples/terraform/flatcar-install/groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
resource "matchbox_group" "default" {
name = "default"
profile = matchbox_profile.flatcar-install.name

# no selector means all machines can be matched
metadata = {
ignition_endpoint = "${var.matchbox_http_endpoint}/ignition"
ssh_authorized_key = var.ssh_authorized_key
}
}

// Match machines which have CoreOS Container Linux installed
resource "matchbox_group" "node1" {
name = "node1"
// Match install stage Flatcar Linux machines
resource "matchbox_group" "stage-1" {
name = "worker"
profile = matchbox_profile.worker.name

selector = {
os = "installed"
}

metadata = {
ssh_authorized_key = var.ssh_authorized_key
}
}
Loading