-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (145 loc) · 4.62 KB
/
sunbeam-multi-node.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Sunbeam Multi-node
on:
# Runs on pushes targeting the default branch
push:
branches: ["act"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
workaround:
description: 'Apply a workaround'
required: true
default: true
type: boolean
hardware_profile:
description: 'Specs for each machine'
required: true
default: minimal
type: choice
options:
- minimal
- minimal-with-cpu-overcommit
- tutorial
- allowance
permissions:
contents: read
env:
COLUMNS: 160 # default: 80
DEBIAN_FRONTEND: noninteractive
defaults:
run:
shell: bash -ex {0}
jobs:
sunbeam-multi-node-tutorial:
name: Sunbeam Multi-node Tutorial
runs-on: [ubuntu-24.04]
steps:
- uses: actions/checkout@v4
- name: Check machine specs
run: |
systemd-detect-virt || true
lscpu
free -h
lsblk
lsblk -f
cat /etc/os-release
ip -br a
ip r
resolvectl --no-pager
# TODO: check if greenfield or brownfield first
- name: Install prerequisites
if: ${{ !env.ACT }}
run: |
sudo apt-get update
sudo apt-get install -y uvtool j2cli
- name: Download a VM image
if: ${{ !env.ACT }}
run: |
sg libvirt 'uvt-simplestreams-libvirt sync release=noble arch=amd64'
sg libvirt 'uvt-simplestreams-libvirt query'
- name: Prepare SSH, virtual network bridge, and virtual machines
if: ${{ !env.ACT }}
run: |
# SSH
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ''
cat <<EOF | tee -a ~/.ssh/config
Host sunbeam-machine-1
User ubuntu
Hostname 192.168.124.11
Host sunbeam-machine-2
User ubuntu
Hostname 192.168.124.12
Host sunbeam-machine-3
User ubuntu
Hostname 192.168.124.13
EOF
# bridge
sg libvirt 'virsh -c qemu:///system net-define /dev/stdin <<EOF
<network>
<name>sunbeam-virbr0</name>
<bridge name="sunbeam-virbr0" stp="off"/>
<forward mode="nat"/>
<ip address="192.168.124.1" netmask="255.255.255.0" />
</network>
EOF
'
sg libvirt 'virsh -c qemu:///system net-autostart sunbeam-virbr0'
sg libvirt 'virsh -c qemu:///system net-start sunbeam-virbr0'
- name: Clean up previous virtual machines
if: ${{ env.ACT }}
run: |
for i in {1..3}; do
# FIXME: the requirement of FQDN is not documented well in each tutorial
sg libvirt "uvt-kvm destroy 'sunbeam-machine-${i}.localdomain'" || true
done
- name: Prepare virtual machines
run: |
for i in {1..3}; do
sg libvirt "uvt-kvm create \
--machine-type q35 \
--cpu '4' \
--host-passthrough \
--memory '$((16 * 1024))' \
--disk '128' \
--ephemeral-disk '128' \
--ephemeral-disk '128' \
--unsafe-caching \
--bridge sunbeam-virbr0 \
--network-config /dev/stdin \
--ssh-public-key-file ~/.ssh/id_ed25519.pub \
--no-start \
sunbeam-machine-${i}.localdomain \
release=noble <<EOF
network:
version: 2
ethernets:
enp1s0:
dhcp4: false
dhcp6: false
accept-ra: false
addresses:
- 192.168.124.1${i}/24
routes:
- to: default
via: 192.168.124.1
nameservers:
addresses:
- 192.168.124.1
EOF
"
done
# secondary NIC
for i in {1..3}; do
sg libvirt "virsh -c qemu:///system attach-interface 'sunbeam-machine-${i}.localdomain' \
network sunbeam-virbr0 \
--model virtio --config
"
done
for i in {1..3}; do
sg libvirt "virsh -c qemu:///system start 'sunbeam-machine-${i}.localdomain'"
done
for i in {1..3}; do
until ssh -oStrictHostKeyChecking=no "sunbeam-machine-${i}" -- 'cloud-init status --wait; ip -br a; lsblk'; do
sleep 5
done
done