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

Add new RAW builoder targets for e.g. 2404 #1669

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ QEMU_BUILD_NAMES ?= qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-ubuntu-2204-cloudim

QEMU_KUBEVIRT_BUILD_NAMES := $(addprefix kubevirt-,$(QEMU_BUILD_NAMES))

RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-flatcar raw-rhel-8 raw-rhel-9 raw-rhel-9-efi
RAW_BUILD_NAMES ?= raw-ubuntu-2004 raw-ubuntu-2004-efi raw-ubuntu-2204 raw-ubuntu-2204-efi raw-ubuntu-2404-efi raw-flatcar raw-rhel-8 raw-rhel-9 raw-rhel-9-efi

POWERVS_BUILD_NAMES ?= powervs-centos-8 powervs-centos-9

Expand Down Expand Up @@ -833,6 +833,9 @@ build-raw-ubuntu-2004-efi: ## Builds Ubuntu 20.04 RAW image that EFI boots
build-raw-rhel-8: ## Builds RHEL 8 RAW image
build-raw-rhel-9: ## Builds RHEL 9 RAW image
build-raw-rhel-9-efi: ## Builds RHEL 9 RAW image that EFI boots
build-raw-ubuntu-2204: ## Builds Ubuntu 22.04 RAW image
build-raw-ubuntu-2204-efi: ## Builds Ubuntu 22.04 RAW image that EFI boots
build-raw-ubuntu-2404-efi: ## Builds Ubuntu 24.04 RAW image that EFI boots
build-raw-all: $(RAW_BUILD_TARGETS) ## Builds all RAW images

build-oci-ubuntu-2004: ## Builds the OCI ubuntu-2004 image
Expand Down Expand Up @@ -1011,6 +1014,8 @@ validate-raw-flatcar: ## Validates Flatcar RAW image packer config
validate-raw-ubuntu-2004: ## Validates Ubuntu 20.04 RAW image packer config
validate-raw-ubuntu-2004-efi: ## Validates Ubuntu 20.04 RAW EFI image packer config
validate-raw-rhel-8: ## Validates RHEL 8 RAW image packer config
validate-raw-ubuntu-2204: ## Validates Ubuntu 22.04 RAW image packer config
validate-raw-ubuntu-2204-efi: ## Validates Ubuntu 22.04 RAW EFI image packer config
validate-raw-all: $(RAW_VALIDATE_TARGETS) ## Validates all RAW Packer config

validate-oci-ubuntu-2004: ## Validates the OCI ubuntu-2004 image packer config
Expand Down
1 change: 1 addition & 0 deletions images/capi/packer/raw/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ ks.cfg
ks-efi.cfg
preseed.cfg
preseed-efi.cfg
user-data
Empty file.
114 changes: 114 additions & 0 deletions images/capi/packer/raw/linux/ubuntu/http/22.04.efi/user-data.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#cloud-config
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# For more information on how autoinstall is configured, please refer to
# https://ubuntu.com/server/docs/install/autoinstall-reference
autoinstall:
version: 1
# Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts
early-commands:
- systemctl stop ssh
# Configure the locale
locale: en_US.UTF-8
keyboard:
layout: us
grub:
reorder_uefi: false
replace_linux_default: false
# For more information on how partitioning is configured,
# please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html.
storage:
swap:
size: 0
grub:
reorder_uefi: false
replace_linux_default: false
config:
- ptable: gpt
path: /dev/sda
wipe: superblock-recursive
preserve: false
name: ''
grub_device: false
type: disk
id: disk-sda
- device: disk-sda
# Create EFI partition of 512MB same as in Ubuntu 20.04
size: 536870912
wipe: superblock
flag: boot
number: 1
preserve: false
grub_device: true
type: partition
id: partition-0
- fstype: fat32
volume: partition-0
preserve: false
type: format
id: format-0
- device: disk-sda
size: -1
wipe: superblock
flag: ''
number: 2
preserve: false
grub_device: false
type: partition
id: partition-1
- fstype: ext4
volume: partition-1
preserve: false
type: format
id: format-1
- path: /
device: format-1
type: mount
id: mount-1
- path: /boot/efi
device: format-0
type: mount
id: mount-0
updates: "all"
ssh:
install-server: true
allow-pw: true
# Create the default user.
# Ensures the "builder" user doesn't require a password to use sudo.
user-data:
users:
- name: builder
# openssl passwd -6 -salt <random salt> -stdin <<< <SSH password>
passwd: $ENCRYPTED_SSH_PASSWORD
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash

# This command runs after all other steps; it:
# 1. Disables swapfiles
# 2. Removes the existing swapfile
# 3. Removes the swapfile entry from /etc/fstab
# 4. Removes snapd, https://bugs.launchpad.net/subiquity/+bug/1946609
# 5. Cleans up any packages that are no longer required
# 6. Removes the cached list of packages
late-commands:
- curtin in-target --target=/target -- swapoff -a
- curtin in-target --target=/target -- rm -f /swap.img
- curtin in-target --target=/target -- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
- chroot /target apt-get purge -y snapd
- curtin in-target --target=/target -- apt-get purge --auto-remove -y
- curtin in-target --target=/target -- apt-get clean
- curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/*
Empty file.
84 changes: 84 additions & 0 deletions images/capi/packer/raw/linux/ubuntu/http/22.04/user-data.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#cloud-config
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# For more information on how autoinstall is configured, please refer to
# https://ubuntu.com/server/docs/install/autoinstall-reference
autoinstall:
version: 1
# Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts
early-commands:
- systemctl stop ssh
# Configure the locale
locale: en_US.UTF-8
keyboard:
layout: us
# Create a single-partition with no swap space. Kubernetes
# really dislikes the idea of anyone else managing memory.
# For more information on how partitioning is configured,
# please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html.
storage:
config:
- type: disk
id: disk-0
size: largest
grub_device: true
preserve: false
ptable: msdos
wipe: superblock
- type: partition
id: partition-0
device: disk-0
size: -1
number: 1
preserve: false
flag: boot
- type: format
id: format-0
volume: partition-0
fstype: ext4
preserve: false
- type: mount
id: mount-0
device: format-0
path: /
updates: 'all'
ssh:
install-server: true
allow-pw: true
# Create the default user.
# Ensures the "builder" user doesn't require a password to use sudo.
user-data:
users:
- name: builder
# openssl passwd -6 -salt <random salt> -stdin <<< <SSH password>
passwd: $ENCRYPTED_SSH_PASSWORD
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash

# This command runs after all other steps; it:
# 1. Disables swapfiles
# 2. Removes the existing swapfile
# 3. Removes the swapfile entry from /etc/fstab
# 4. Cleans up any packages that are no longer required
# 5. Removes the cached list of packages
late-commands:
- swapoff -a
- rm -f /swapfile
- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
- apt-get purge --auto-remove -y
- rm -rf /var/lib/apt/lists/*
Empty file.
114 changes: 114 additions & 0 deletions images/capi/packer/raw/linux/ubuntu/http/24.04.efi/user-data.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#cloud-config
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# For more information on how autoinstall is configured, please refer to
# https://ubuntu.com/server/docs/install/autoinstall-reference
autoinstall:
version: 1
# Disable ssh server during installation, otherwise packer tries to connect and exceed max attempts
early-commands:
- systemctl stop ssh
# Configure the locale
locale: en_US.UTF-8
keyboard:
layout: us
grub:
reorder_uefi: false
replace_linux_default: false
# For more information on how partitioning is configured,
# please refer to https://curtin.readthedocs.io/en/latest/topics/storage.html.
storage:
swap:
size: 0
grub:
reorder_uefi: false
replace_linux_default: false
config:
- ptable: gpt
path: /dev/sda
wipe: superblock-recursive
preserve: false
name: ''
grub_device: false
type: disk
id: disk-sda
- device: disk-sda
# Create EFI partition of 512MB same as in Ubuntu 20.04
size: 536870912
wipe: superblock
flag: boot
number: 1
preserve: false
grub_device: true
type: partition
id: partition-0
- fstype: fat32
volume: partition-0
preserve: false
type: format
id: format-0
- device: disk-sda
size: -1
wipe: superblock
flag: ''
number: 2
preserve: false
grub_device: false
type: partition
id: partition-1
- fstype: ext4
volume: partition-1
preserve: false
type: format
id: format-1
- path: /
device: format-1
type: mount
id: mount-1
- path: /boot/efi
device: format-0
type: mount
id: mount-0
updates: "all"
ssh:
install-server: true
allow-pw: true
# Create the default user.
# Ensures the "builder" user doesn't require a password to use sudo.
user-data:
users:
- name: builder
# openssl passwd -6 -salt <random salt> -stdin <<< <SSH password>
passwd: $ENCRYPTED_SSH_PASSWORD
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash

# This command runs after all other steps; it:
# 1. Disables swapfiles
# 2. Removes the existing swapfile
# 3. Removes the swapfile entry from /etc/fstab
# 4. Removes snapd, https://bugs.launchpad.net/subiquity/+bug/1946609
# 5. Cleans up any packages that are no longer required
# 6. Removes the cached list of packages
late-commands:
- curtin in-target --target=/target -- swapoff -a
- curtin in-target --target=/target -- rm -f /swap.img
- curtin in-target --target=/target -- sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
- chroot /target apt-get purge -y snapd
- curtin in-target --target=/target -- apt-get purge --auto-remove -y
- curtin in-target --target=/target -- apt-get clean
- curtin in-target --target=/target -- rm -rf /var/lib/apt/lists/*
10 changes: 8 additions & 2 deletions images/capi/packer/raw/packer.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"net_device": "virtio-net",
"output_directory": "{{user `output_directory`}}",
"qemu_binary": "{{user `qemu_binary`}}",
"qemuargs": [
[
"-vga",
"virtio"
]
],
"shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S -E sh -c 'usermod -L {{user `ssh_username`}} && {{user `shutdown_command`}}'",
"ssh_password": "{{user `ssh_password`}}",
"ssh_timeout": "2h",
Expand Down Expand Up @@ -86,7 +92,7 @@
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} -o IdentitiesOnly=yes'"
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
Expand Down Expand Up @@ -179,6 +185,6 @@
"qemu_binary": "qemu-system-x86_64",
"ssh_password": "$SSH_PASSWORD",
"ssh_username": "builder",
"vm_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}"
"vm_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}"
}
}
3 changes: 3 additions & 0 deletions images/capi/packer/raw/raw-ubuntu-2004-efi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"boot_command_suffix": "/20.04/preseed-efi.cfg -- <wait><enter>initrd /install/initrd.gz<enter>boot<enter><wait>",
"build_name": "ubuntu-2004",
"build_target": "raw",
"distro_arch": "amd64",
"distro_name": "ubuntu",
"distro_version": "20.04",
"distro_version_slug": "2004",
"firmware": "OVMF.fd",
"guest_os_type": "ubuntu-64",
"iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
Expand Down
3 changes: 3 additions & 0 deletions images/capi/packer/raw/raw-ubuntu-2004.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"boot_command_suffix": "/20.04/preseed.cfg -- <wait><enter><wait>",
"build_name": "ubuntu-2004",
"build_target": "raw",
"distro_arch": "amd64",
"distro_name": "ubuntu",
"distro_version": "20.04",
"distro_version_slug": "2004",
"guest_os_type": "ubuntu-64",
"iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
"iso_checksum_type": "sha256",
Expand Down
Loading