Skip to content

Commit c7b3cff

Browse files
committed
ARM64 support for MaaS
1 parent 2561c79 commit c7b3cff

15 files changed

Lines changed: 581 additions & 9 deletions

File tree

images/capi/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ PROXMOX_BUILD_NAMES ?= proxmox-ubuntu-2204 proxmox-ubuntu-2404 proxmox-ubuntu-
405405

406406
VULTR_BUILD_NAMES ?= vultr-ubuntu-2204 vultr-ubuntu-2404
407407

408-
MAAS_BUILD_NAMES ?= maas-ubuntu-2204-efi maas-ubuntu-2404-efi
408+
MAAS_BUILD_NAMES ?= maas-ubuntu-2204-efi maas-ubuntu-2404-efi
409+
MAAS_ARM64_BUILD_NAMES ?= maas-ubuntu-2204-arm64 maas-ubuntu-2404-arm64
409410

410411
SCALEWAY_BUILD_NAMES ?= scaleway-rockylinux-9 scaleway-ubuntu-2204 scaleway-ubuntu-2404
411412

@@ -459,6 +460,8 @@ VULTR_BUILD_TARGETS := $(addprefix build-,$(VULTR_BUILD_NAMES))
459460
VULTR_VALIDATE_TARGETS := $(addprefix validate-,$(VULTR_BUILD_NAMES))
460461
MAAS_BUILD_TARGETS := $(addprefix build-,$(MAAS_BUILD_NAMES))
461462
MAAS_VALIDATE_TARGETS := $(addprefix validate-,$(MAAS_BUILD_NAMES))
463+
MAAS_ARM64_BUILD_TARGETS := $(addprefix build-,$(MAAS_ARM64_BUILD_NAMES))
464+
MAAS_ARM64_VALIDATE_TARGETS := $(addprefix validate-,$(MAAS_ARM64_BUILD_NAMES))
462465
SCALEWAY_BUILD_TARGETS := $(addprefix build-,$(SCALEWAY_BUILD_NAMES))
463466
SCALEWAY_VALIDATE_TARGETS := $(addprefix validate-,$(SCALEWAY_BUILD_NAMES))
464467

@@ -664,6 +667,14 @@ $(MAAS_BUILD_TARGETS): deps-qemu set-ssh-password
664667
$(MAAS_VALIDATE_TARGETS): deps-qemu set-ssh-password
665668
$(PACKER) validate $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/maas/$(subst validate-,,$@).json)" --var="ansible_user_vars=provider=maas" $(ABSOLUTE_PACKER_VAR_FILES) packer/maas/packer.json
666669

670+
.PHONY: $(MAAS_ARM64_BUILD_TARGETS)
671+
$(MAAS_ARM64_BUILD_TARGETS): deps-qemu set-ssh-password
672+
$(PACKER) build $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/maas/$(subst build-,,$@).json)" --var="ansible_user_vars=provider=maas" $(ABSOLUTE_PACKER_VAR_FILES) packer/maas/packer-arm64.json
673+
674+
.PHONY: $(MAAS_ARM64_VALIDATE_TARGETS)
675+
$(MAAS_ARM64_VALIDATE_TARGETS): deps-qemu set-ssh-password
676+
$(PACKER) validate $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/maas/$(subst validate-,,$@).json)" --var="ansible_user_vars=provider=maas" $(ABSOLUTE_PACKER_VAR_FILES) packer/maas/packer-arm64.json
677+
667678
.PHONY: $(SCALEWAY_BUILD_TARGETS)
668679
$(SCALEWAY_BUILD_TARGETS): deps-scaleway
669680
$(PACKER) build $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/scaleway/$(subst build-scaleway-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/scaleway/packer.json
@@ -831,6 +842,8 @@ build-qemu-all: $(QEMU_BUILD_TARGETS) ## Builds all Qemu images
831842

832843
build-maas-ubuntu-2204-efi: ## Builds Ubuntu 22.04 MaaS image that EFI boots
833844
build-maas-ubuntu-2404-efi: ## Builds Ubuntu 24.04 MaaS image that EFI boots
845+
build-maas-ubuntu-2204-arm64: ## Builds Ubuntu 22.04 ARM64 MaaS image that EFI boots
846+
build-maas-ubuntu-2404-arm64: ## Builds Ubuntu 24.04 ARM64 MaaS image that EFI boots
834847

835848
build-raw-flatcar: ## Builds Flatcar RAW image
836849
build-raw-ubuntu-2204: ## Builds Ubuntu 22.04 RAW image

images/capi/ansible/roles/firstboot/meta/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,20 @@ dependencies:
1919
debs: ""
2020
when: ansible_os_family == "VMware Photon OS"
2121

22+
- role: setup
23+
vars:
24+
rpms: >-
25+
{{ ( common_rpms + rh8_rpms + lookup('vars', 'common_' + build_target + '_rpms') ) }}
26+
debs: "{{ common_debs + lookup('vars', 'common_' + build_target + '_debs_arm64') }}"
27+
when: >
28+
packer_builder_type is search('qemu')
29+
and ansible_architecture == "aarch64"
30+
2231
- role: setup
2332
vars:
2433
rpms: >-
2534
{{ ( common_rpms + rh8_rpms + lookup('vars', 'common_' + build_target + '_rpms') ) }}
2635
debs: "{{ common_debs + lookup('vars', 'common_' + build_target + '_debs') }}"
27-
when: packer_builder_type is search('qemu')
36+
when: >
37+
packer_builder_type is search('qemu')
38+
and ansible_architecture != "aarch64"

images/capi/ansible/roles/node/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ photon_5_rpms:
102102
common_virt_rpms:
103103
- open-vm-tools
104104

105+
common_virt_debs_arm64:
106+
- linux-tools-virtual
107+
- open-vm-tools
108+
105109
common_virt_debs:
106110
- linux-cloud-tools-virtual
107111
- linux-tools-virtual

images/capi/ansible/roles/providers/tasks/qemu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
name: hv-kvp-daemon
4141
state: stopped
4242
enabled: false
43-
when: ansible_os_family == "Debian"
43+
when: ansible_os_family == "Debian" and ansible_architecture != "aarch64"
4444

4545
- name: Create directory for DHCP chrony server files
4646
ansible.builtin.file:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Types: deb
2-
URIs: http://us.archive.ubuntu.com/ubuntu/
2+
URIs: {{ ubuntu_repo }}/
33
Suites: {{ ansible_distribution_release }} {{ ansible_distribution_release }}-updates {{ ansible_distribution_release }}-backports
44
Components: main restricted universe multiverse
55
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
66

77
Types: deb
8-
URIs: http://security.ubuntu.com/ubuntu/
8+
URIs: {{ ubuntu_security_repo }}/
99
Suites: {{ ansible_distribution_release }}-security
1010
Components: main restricted universe multiverse
1111
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

images/capi/packer/goss/goss-vars.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ ubuntu:
496496
enabled: true
497497
running: true
498498
package:
499-
linux-cloud-tools-virtual:
499+
#linux-cloud-tools-virtual:
500500
linux-tools-virtual:
501501
open-vm-tools:
502502
cloud-guest-utils:

images/capi/packer/maas/README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,60 @@
1+
# Prereqs
2+
3+
Assuming you're building on Ubuntu:
4+
```
5+
apt update
6+
apt install -y make jq unzip python3-pip
7+
cd images/capi
8+
make deps-qemu
9+
```
10+
11+
If you will be building ARM64 images, ensure you run the builder on a native ARM64 server and add these additional prereqs:
12+
```
13+
apt-get install qemu-system-arm libvirt-daemon-system -y
14+
15+
# create EFI disk images for ARM64
16+
pushd /var/lib/libvirt/images/
17+
dd if=/dev/zero of=capi.fd bs=1M count=64
18+
dd if=/dev/zero of=capi-nvmram.fd bs=1M count=64
19+
dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=capi.fd conv=notrunc
20+
popd
21+
```
22+
23+
# Building
24+
125
To build an image using a specific version of Kubernetes use the "PACKER_FLAGS" env var like in the example below:
226

27+
For AMD64:
28+
```
29+
export PATH=/root/.local/bin:$PATH
30+
331
PACKER_FLAGS="--var 'kubernetes_rpm_version=1.30.5' --var 'kubernetes_semver=v1.30.5' --var 'kubernetes_series=v1.30' --var 'kubernetes_deb_version=1.30.5-1.1'" make build-maas-ubuntu-2204-efi
32+
```
33+
34+
For ARM64:
35+
```
36+
export PATH=/root/.local/bin:$PATH
37+
38+
ARCH=arm64 PACKER_FLAGS="--var 'kubernetes_rpm_version=1.30.5' --var 'kubernetes_semver=v1.30.5' --var 'kubernetes_series=v1.30' --var 'kubernetes_deb_version=1.30.5-1.1'" make build-maas-ubuntu-2204-arm64
39+
```
440

541
P.S: In order to change disk size(defaults to 20GB as of 31.10.22) you can update PACKER_FLAGS with:
642
--var 'disk_size=<disk size in mb>'
743

44+
# Uploading to MaaS
845

9-
Upload images to MaaS
46+
To upload the generates images to MaaS, run the following command.
1047

48+
For AMD64:
49+
```
50+
maas <PROFILE> boot-resources create name=<IMAGE NAME> architecture=amd64/generic title=<IMAGE NAME> base_image=ubuntu/<SEE NOTES> content@=./<FILE>.tar.gz
1151
```
12-
maas <PROFILE> boot-resources create name=custom/<IMAGE NAME> architecture=amd64/generic title=<IMAGE NAME> subarches=generic base_image=ubuntu/<SEE NOTES> content@=./<FILE>.tar.gz
52+
53+
For ARM64:
1354
```
55+
maas <PROFILE> boot-resources create name=<IMAGE NAME> architecture=arm64/generic title=<IMAGE NAME> base_image=ubuntu/<SEE NOTES> content@=./<FILE>.tar.gz
56+
```
57+
1458

1559
Notes / Things you need to known:
1660

images/capi/packer/maas/linux/ubuntu/http/22.04.arm64/meta-data

Whitespace-only changes.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#cloud-config
2+
# Copyright 2022 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# For more information on how autoinstall is configured, please refer to
17+
# https://ubuntu.com/server/docs/install/autoinstall-reference
18+
autoinstall:
19+
version: 1
20+
# Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts
21+
early-commands:
22+
- systemctl stop ssh
23+
# Configure the locale
24+
locale: en_US.UTF-8
25+
keyboard:
26+
layout: us
27+
# For more information on how partitioning is configured,
28+
# please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html.
29+
storage:
30+
grub:
31+
reorder_uefi: false
32+
replace_linux_default: false
33+
config:
34+
- ptable: gpt
35+
path: /dev/vda
36+
wipe: superblock-recursive
37+
preserve: false
38+
name: ''
39+
grub_device: false
40+
type: disk
41+
id: disk-vda
42+
- device: disk-vda
43+
# Create EFI partition of 512MB same as in Ubuntu 20.04
44+
size: 536870912
45+
wipe: superblock
46+
flag: boot
47+
number: 1
48+
preserve: false
49+
grub_device: true
50+
type: partition
51+
id: partition-0
52+
- fstype: fat32
53+
volume: partition-0
54+
preserve: false
55+
type: format
56+
id: format-0
57+
- device: disk-vda
58+
size: -1
59+
wipe: superblock
60+
flag: ''
61+
number: 2
62+
preserve: false
63+
grub_device: false
64+
type: partition
65+
id: partition-1
66+
- fstype: ext4
67+
volume: partition-1
68+
preserve: false
69+
type: format
70+
id: format-1
71+
- path: /
72+
device: format-1
73+
type: mount
74+
id: mount-1
75+
- path: /boot/efi
76+
device: format-0
77+
type: mount
78+
id: mount-0
79+
updates: "all"
80+
ssh:
81+
install-server: true
82+
allow-pw: true
83+
# Create the default user.
84+
# Ensures the "builder" user doesn't require a password to use sudo.
85+
user-data:
86+
users:
87+
- name: builder
88+
# openssl passwd -6 -salt <random salt> -stdin <<< <SSH password>
89+
passwd: $ENCRYPTED_SSH_PASSWORD
90+
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
91+
lock-passwd: false
92+
sudo: ALL=(ALL) NOPASSWD:ALL
93+
shell: /bin/bash
94+
95+
# This command runs after all other steps; it:
96+
# 1. Disables swapfiles
97+
# 2. Removes the existing swapfile
98+
# 3. Removes the swapfile entry from /etc/fstab
99+
# 4. Cleans up any packages that are no longer required
100+
# 5. Removes the cached list of packages
101+
late-commands:
102+
- swapoff -a
103+
- rm -f /swapfile
104+
- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
105+
- apt-get purge --auto-remove -y
106+
- rm -rf /var/lib/apt/lists/*

images/capi/packer/maas/linux/ubuntu/http/24.04.arm64/meta-data

Whitespace-only changes.

0 commit comments

Comments
 (0)