This commit is contained in:
11
packer/qemu/OWNERS
Normal file
11
packer/qemu/OWNERS
Normal file
@ -0,0 +1,11 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
approvers:
|
||||
- cluster-api-openstack-maintainers
|
||||
- cluster-api-cloudstack-maintainers
|
||||
|
||||
reviewers:
|
||||
- cluster-api-openstack-maintainers
|
||||
- image-builder-openstack-reviewers
|
||||
- cluster-api-cloudstack-maintainers
|
||||
- image-builder-cloudstack-reviewers
|
6
packer/qemu/README.md
Normal file
6
packer/qemu/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
To build an image using a specific version of Kubernetes use the "PACKER_FLAGS" env var like in the example below:
|
||||
|
||||
PACKER_FLAGS="--var 'kubernetes_rpm_version=1.25.3-0' --var 'kubernetes_semver=v1.25.3' --var 'kubernetes_series=v1.25' --var 'kubernetes_deb_version=1.25.3-00'" make build-kubevirt-qemu-ubuntu-2004
|
||||
|
||||
P.S: In order to change disk size(defaults to 20GB as of 31.10.22) you can update PACKER_FLAGS with:
|
||||
--var 'disk_size=<disk size in mb>'
|
1
packer/qemu/linux
Symbolic link
1
packer/qemu/linux
Symbolic link
@ -0,0 +1 @@
|
||||
../ova/linux
|
194
packer/qemu/packer.json
Normal file
194
packer/qemu/packer.json
Normal file
@ -0,0 +1,194 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"accelerator": "{{user `accelerator`}}",
|
||||
"boot_command": [
|
||||
"{{user `boot_command_prefix`}}",
|
||||
"{{user `boot_media_path`}}",
|
||||
"{{user `boot_command_suffix`}}"
|
||||
],
|
||||
"boot_wait": "{{user `boot_wait`}}",
|
||||
"cpus": "{{user `cpus`}}",
|
||||
"disk_compression": "{{ user `disk_compression`}}",
|
||||
"disk_discard": "{{user `disk_discard`}}",
|
||||
"disk_interface": "virtio-scsi",
|
||||
"disk_size": "{{user `disk_size`}}",
|
||||
"firmware": "{{user `firmware`}}",
|
||||
"format": "{{user `format`}}",
|
||||
"headless": "{{user `headless`}}",
|
||||
"http_directory": "{{user `http_directory`}}",
|
||||
"iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}",
|
||||
"iso_url": "{{user `iso_url`}}",
|
||||
"memory": "{{user `memory`}}",
|
||||
"net_device": "virtio-net",
|
||||
"output_directory": "{{user `output_directory`}}",
|
||||
"qemu_binary": "{{user `qemu_binary`}}",
|
||||
"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",
|
||||
"ssh_username": "{{user `ssh_username`}}",
|
||||
"type": "qemu",
|
||||
"vm_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
{
|
||||
"environment_vars": [
|
||||
"CUSTOM_POST_PROCESSOR={{user `custom_post_processor`}}"
|
||||
],
|
||||
"inline": [
|
||||
"if [ \"$CUSTOM_POST_PROCESSOR\" != \"true\" ]; then exit 0; fi",
|
||||
"{{user `custom_post_processor_command`}}"
|
||||
],
|
||||
"name": "custom-post-processor",
|
||||
"type": "shell-local"
|
||||
},
|
||||
{
|
||||
"environment_vars": [
|
||||
"OUTPUT_DIR={{user `output_directory`}}",
|
||||
"ARTIFACT_NAME={{user `artifact_name`}}",
|
||||
"KUBEVIRT={{user `kubevirt`}}"
|
||||
],
|
||||
"inline": [
|
||||
"if [ \"$KUBEVIRT\" != \"true\" ]; then",
|
||||
"exit 0",
|
||||
"else",
|
||||
"bash ./packer/qemu/scripts/build_kubevirt_image.sh {{user `build_name`}}-container-disk",
|
||||
"fi"
|
||||
],
|
||||
"name": "kubevirt",
|
||||
"type": "shell-local"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"execute_command": "BUILD_NAME={{user `build_name`}}; if [[ \"${BUILD_NAME}\" == *\"flatcar\"* ]]; then sudo {{.Vars}} -S -E bash '{{.Path}}'; fi",
|
||||
"script": "./packer/files/flatcar/scripts/bootstrap-flatcar.sh",
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"ansible_env_vars": [
|
||||
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'",
|
||||
"KUBEVIRT={{user `kubevirt`}}"
|
||||
],
|
||||
"extra_arguments": [
|
||||
"--extra-vars",
|
||||
"{{user `ansible_common_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_extra_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_user_vars`}}",
|
||||
"--scp-extra-args",
|
||||
"{{user `ansible_scp_extra_args`}}"
|
||||
],
|
||||
"playbook_file": "./ansible/firstboot.yml",
|
||||
"type": "ansible",
|
||||
"user": "builder"
|
||||
},
|
||||
{
|
||||
"expect_disconnect": true,
|
||||
"inline": [
|
||||
"sudo reboot now"
|
||||
],
|
||||
"inline_shebang": "/bin/bash -e",
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"ansible_env_vars": [
|
||||
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'",
|
||||
"KUBEVIRT={{user `kubevirt`}}"
|
||||
],
|
||||
"extra_arguments": [
|
||||
"--extra-vars",
|
||||
"{{user `ansible_common_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_extra_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_user_vars`}}",
|
||||
"--scp-extra-args",
|
||||
"{{user `ansible_scp_extra_args`}}"
|
||||
],
|
||||
"playbook_file": "./ansible/node.yml",
|
||||
"type": "ansible",
|
||||
"user": "builder"
|
||||
},
|
||||
{
|
||||
"arch": "{{user `goss_arch`}}",
|
||||
"format": "{{user `goss_format`}}",
|
||||
"format_options": "{{user `goss_format_options`}}",
|
||||
"goss_file": "{{user `goss_entry_file`}}",
|
||||
"inspect": "{{user `goss_inspect_mode`}}",
|
||||
"tests": [
|
||||
"{{user `goss_tests_dir`}}"
|
||||
],
|
||||
"type": "goss",
|
||||
"url": "{{user `goss_url`}}",
|
||||
"use_sudo": true,
|
||||
"vars_file": "{{user `goss_vars_file`}}",
|
||||
"vars_inline": {
|
||||
"ARCH": "amd64",
|
||||
"OS": "{{user `distro_name` | lower}}",
|
||||
"PROVIDER": "qemu",
|
||||
"containerd_version": "{{user `containerd_version`}}",
|
||||
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
|
||||
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
|
||||
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
|
||||
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
|
||||
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
|
||||
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
|
||||
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
|
||||
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
|
||||
},
|
||||
"version": "{{user `goss_version`}}"
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"accelerator": "kvm",
|
||||
"ansible_common_vars": "",
|
||||
"ansible_extra_vars": "ansible_python_interpreter=/usr/bin/python3",
|
||||
"ansible_user_vars": "",
|
||||
"artifact_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}",
|
||||
"boot_media_path": "http://{{ .HTTPIP }}:{{ .HTTPPort }}",
|
||||
"boot_wait": "10s",
|
||||
"build_timestamp": "{{timestamp}}",
|
||||
"containerd_sha256": null,
|
||||
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
|
||||
"containerd_version": null,
|
||||
"cpus": "1",
|
||||
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
|
||||
"crictl_version": null,
|
||||
"disk_compression": "false",
|
||||
"disk_discard": "unmap",
|
||||
"disk_size": "20480",
|
||||
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
|
||||
"firmware": "",
|
||||
"format": "qcow2",
|
||||
"headless": "true",
|
||||
"http_directory": "./packer/qemu/linux/{{user `distro_name`}}/http/",
|
||||
"kubernetes_cni_deb_version": null,
|
||||
"kubernetes_cni_http_source": null,
|
||||
"kubernetes_cni_semver": null,
|
||||
"kubernetes_cni_source_type": null,
|
||||
"kubernetes_container_registry": null,
|
||||
"kubernetes_deb_gpg_key": null,
|
||||
"kubernetes_deb_repo": null,
|
||||
"kubernetes_deb_version": null,
|
||||
"kubernetes_http_source": null,
|
||||
"kubernetes_load_additional_imgs": null,
|
||||
"kubernetes_rpm_gpg_check": null,
|
||||
"kubernetes_rpm_gpg_key": null,
|
||||
"kubernetes_rpm_repo": null,
|
||||
"kubernetes_rpm_version": null,
|
||||
"kubernetes_semver": null,
|
||||
"kubernetes_series": null,
|
||||
"kubernetes_source_type": null,
|
||||
"machine_id_mode": "444",
|
||||
"memory": "2048",
|
||||
"oem_id": "",
|
||||
"output_directory": "./output/{{user `build_name`}}-kube-{{user `kubernetes_semver`}}",
|
||||
"python_path": "",
|
||||
"qemu_binary": "qemu-system-x86_64",
|
||||
"ssh_password": "builder",
|
||||
"ssh_username": "builder"
|
||||
}
|
||||
}
|
15
packer/qemu/qemu-centos-7.json
Normal file
15
packer/qemu/qemu-centos-7.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"ansible_extra_vars": "ansible_python_interpreter=/usr/bin/python extra_arguments =vvvv",
|
||||
"boot_command_prefix": "<tab> text ks=",
|
||||
"boot_command_suffix": "/7/ks.cfg<enter><wait>",
|
||||
"build_name": "centos-7",
|
||||
"distro_arch": "amd64",
|
||||
"distro_name": "centos",
|
||||
"distro_version": "7",
|
||||
"guest_os_type": "centos7-64",
|
||||
"iso_checksum": "07b94e6b1a0b0260b94c83d6bb76b26bf7a310dc78d7a9c7432809fb9bc6194a",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://mirrors.edge.kernel.org/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso",
|
||||
"os_display_name": "CentOS 7",
|
||||
"shutdown_command": "sys-unconfig"
|
||||
}
|
25
packer/qemu/qemu-flatcar.json
Normal file
25
packer/qemu/qemu-flatcar.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"ansible_extra_vars": "ansible_python_interpreter=/opt/bin/python oem_id={{user `oem_id`}}",
|
||||
"boot_command_prefix": "sudo systemctl mask sshd.socket --now<enter>curl -sLo /tmp/ignition.json ",
|
||||
"boot_command_suffix": "/bootstrap.json<enter>sed -i \"s|BUILDERPASSWORDHASH|$(mkpasswd -5 {{user `ssh_password`}})|\" /tmp/ignition.json<enter>sudo flatcar-install -d /dev/sda -C {{user `channel_name`}} -V {{user `release_version`}} -i /tmp/ignition.json<enter>sudo reboot<enter>",
|
||||
"boot_wait": "120s",
|
||||
"build_name": "flatcar-{{env `FLATCAR_CHANNEL`}}-{{env `FLATCAR_VERSION`}}",
|
||||
"channel_name": "{{env `FLATCAR_CHANNEL`}}",
|
||||
"crictl_source_type": "http",
|
||||
"distro_name": "flatcar",
|
||||
"guest_os_type": "linux-64",
|
||||
"http_directory": "./packer/files/flatcar/ignition/",
|
||||
"iso_checksum": "https://{{env `FLATCAR_CHANNEL`}}.release.flatcar-linux.net/amd64-usr/{{env `FLATCAR_VERSION`}}/flatcar_production_iso_image.iso.DIGESTS.asc",
|
||||
"iso_checksum_type": "file",
|
||||
"iso_url": "https://{{env `FLATCAR_CHANNEL`}}.release.flatcar-linux.net/amd64-usr/{{env `FLATCAR_VERSION`}}/flatcar_production_iso_image.iso",
|
||||
"kubernetes_cni_source_type": "http",
|
||||
"kubernetes_source_type": "http",
|
||||
"oem_id": "{{env `OEM_ID`}}",
|
||||
"os_display_name": "Flatcar Container Linux ({{env `FLATCAR_CHANNEL`}} channel release {{env `FLATCAR_VERSION`}})",
|
||||
"python_path": "/opt/bin/builder-env/site-packages",
|
||||
"release_version": "{{env `FLATCAR_VERSION`}}",
|
||||
"shutdown_command": "shutdown -P now",
|
||||
"systemd_prefix": "/etc/systemd",
|
||||
"sysusr_prefix": "/opt",
|
||||
"sysusrlocal_prefix": "/opt"
|
||||
}
|
15
packer/qemu/qemu-rhel-8.json
Normal file
15
packer/qemu/qemu-rhel-8.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"boot_command_prefix": "<tab> text inst.ks=",
|
||||
"boot_command_suffix": "/8/ks.cfg<enter><wait>",
|
||||
"build_name": "rhel-8",
|
||||
"distro_name": "rhel",
|
||||
"distro_version": "8",
|
||||
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8",
|
||||
"guest_os_type": "RedHat_64",
|
||||
"iso_checksum": "48f955712454c32718dcde858dea5aca574376a1d7a4b0ed6908ac0b85597811",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "rhel-8.4-x86_64-dvd.iso",
|
||||
"os_display_name": "RHEL 8",
|
||||
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm",
|
||||
"shutdown_command": "shutdown -P now"
|
||||
}
|
16
packer/qemu/qemu-rockylinux-8.json
Normal file
16
packer/qemu/qemu-rockylinux-8.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"boot_command_prefix": "<up><tab> text inst.ks=",
|
||||
"boot_command_suffix": "/8/ks.cfg<enter><wait><enter>",
|
||||
"build_name": "rockylinux-8",
|
||||
"distro_arch": "amd64",
|
||||
"distro_name": "rockylinux",
|
||||
"distro_version": "8",
|
||||
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8",
|
||||
"guest_os_type": "centos8-64",
|
||||
"iso_checksum": "13c3e7fca1fd32df61695584baafc14fa28d62816d0813116d23744f5394624b",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-8.7-x86_64-minimal.iso",
|
||||
"os_display_name": "RockyLinux 8",
|
||||
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm",
|
||||
"shutdown_command": "/sbin/halt -h -p"
|
||||
}
|
12
packer/qemu/qemu-ubuntu-1804.json
Normal file
12
packer/qemu/qemu-ubuntu-1804.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"boot_command_prefix": "<esc><wait><esc><wait><enter><wait>/install/vmlinuz auto console-setup/ask_detect=false console-setup/layoutcode=us console-setup/modelcode=pc105 debconf/frontend=noninteractive debian-installer=en_US fb=false initrd=/install/initrd.gz kbd-chooser/method=us keyboard-configuration/layout=USA keyboard-configuration/variant=USA locale=en_US netcfg/get_domain=local netcfg/get_hostname=localhost grub-installer/bootdev=/dev/sda preseed/url=",
|
||||
"boot_command_suffix": "/18.04/preseed.cfg -- <enter>",
|
||||
"build_name": "ubuntu-1804",
|
||||
"distro_name": "ubuntu",
|
||||
"guest_os_type": "ubuntu-64",
|
||||
"iso_checksum": "f5cbb8104348f0097a8e513b10173a07dbc6684595e331cb06f93f385d0aecf6",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04.6-server-amd64.iso",
|
||||
"os_display_name": "Ubuntu 18.04",
|
||||
"shutdown_command": "shutdown -P now"
|
||||
}
|
13
packer/qemu/qemu-ubuntu-2004-efi.json
Normal file
13
packer/qemu/qemu-ubuntu-2004-efi.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"boot_command_prefix": "<esc><wait><esc><wait><enter><wait>linux /install/vmlinuz auto console-setup/ask_detect=false console-setup/layoutcode=us console-setup/modelcode=pc105 debconf/frontend=noninteractive debian-installer=en_US fb=false kbd-chooser/method=us keyboard-configuration/layout=USA keyboard-configuration/variant=USA locale=en_US netcfg/get_domain=local netcfg/get_hostname=localhost preseed/url=",
|
||||
"boot_command_suffix": "/20.04/preseed-efi.cfg -- <wait><enter>initrd /install/initrd.gz<enter>boot<enter><wait>",
|
||||
"build_name": "ubuntu-2004",
|
||||
"distro_name": "ubuntu",
|
||||
"firmware": "OVMF.fd",
|
||||
"guest_os_type": "ubuntu-64",
|
||||
"iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04.1-legacy-server-amd64.iso",
|
||||
"os_display_name": "Ubuntu 20.04",
|
||||
"shutdown_command": "shutdown -P now"
|
||||
}
|
12
packer/qemu/qemu-ubuntu-2004.json
Normal file
12
packer/qemu/qemu-ubuntu-2004.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"boot_command_prefix": "<esc><wait><esc><wait><enter><wait>/install/vmlinuz auto console-setup/ask_detect=false console-setup/layoutcode=us console-setup/modelcode=pc105 debconf/frontend=noninteractive debian-installer=en_US fb=false initrd=/install/initrd.gz kbd-chooser/method=us keyboard-configuration/layout=USA keyboard-configuration/variant=USA locale=en_US netcfg/get_domain=local netcfg/get_hostname=localhost grub-installer/bootdev=/dev/sda preseed/url=",
|
||||
"boot_command_suffix": "/20.04/preseed.cfg -- <wait><enter><wait>",
|
||||
"build_name": "ubuntu-2004",
|
||||
"distro_name": "ubuntu",
|
||||
"guest_os_type": "ubuntu-64",
|
||||
"iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04.1-legacy-server-amd64.iso",
|
||||
"os_display_name": "Ubuntu 20.04",
|
||||
"shutdown_command": "shutdown -P now"
|
||||
}
|
12
packer/qemu/qemu-ubuntu-2204.json
Normal file
12
packer/qemu/qemu-ubuntu-2204.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"boot_command_prefix": "c<wait>linux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'<enter><wait>initrd /casper/initrd<enter><wait>boot<enter>",
|
||||
"build_name": "ubuntu-2204",
|
||||
"distro_name": "ubuntu",
|
||||
"guest_os_type": "ubuntu-64",
|
||||
"iso_checksum": "10f19c5b2b8d6db711582e0e27f5116296c34fe4b313ba45f9b201a5007056cb",
|
||||
"iso_checksum_type": "sha256",
|
||||
"iso_url": "https://releases.ubuntu.com/22.04/ubuntu-22.04.1-live-server-amd64.iso",
|
||||
"os_display_name": "Ubuntu 22.04",
|
||||
"shutdown_command": "shutdown -P now",
|
||||
"unmount_iso": "true"
|
||||
}
|
15
packer/qemu/scripts/build_kubevirt_image.sh
Normal file
15
packer/qemu/scripts/build_kubevirt_image.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "OUTPUT_DIR:$OUTPUT_DIR"
|
||||
echo "ARTIFACT_NAME:$ARTIFACT_NAME"
|
||||
echo "########"
|
||||
env
|
||||
cd $OUTPUT_DIR
|
||||
|
||||
echo "FROM registry.access.redhat.com/ubi8/ubi:latest AS builder
|
||||
ADD --chown=107:107 $ARTIFACT_NAME /disk/image.qcow2
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /disk/* /disk/" > ./kubevirt-Dockerfile
|
||||
|
||||
docker build -f ./kubevirt-Dockerfile . -t $1
|
Reference in New Issue
Block a user