diff --git a/images/capi/Makefile b/images/capi/Makefile index ecfec48e9..1e68960dd 100644 --- a/images/capi/Makefile +++ b/images/capi/Makefile @@ -389,7 +389,7 @@ NUTANIX_BUILD_NAMES ?= nutanix-ubuntu-2004 nutanix-ubuntu-2204 nutanix-ubuntu-24 HCLOUD_BUILD_NAMES ?= hcloud-ubuntu-2004 hcloud-ubuntu-2204 hcloud-ubuntu-2404 hcloud-centos-7 hcloud-rockylinux-8 hcloud-rockylinux-9 hcloud-flatcar -PROXMOX_BUILD_NAMES ?= proxmox-ubuntu-2204 proxmox-ubuntu-2404 proxmox-rockylinux-9 +PROXMOX_BUILD_NAMES ?= proxmox-ubuntu-2204 proxmox-ubuntu-2404 proxmox-rockylinux-9 proxmox-flatcar VULTR_BUILD_NAMES ?= vultr-ubuntu-2204 @@ -866,6 +866,7 @@ build-hcloud-rockylinux-9: ## Builds the Hetzner Cloud Rocky Linux 9 image build-hcloud-flatcar: ## Builds the Hetzner Cloud Flatcar image build-hcloud-all: $(HCLOUD_BUILD_TARGETS) ## Builds all Hetzner Cloud image +build-proxmox-flatcar: ## Builds Flatcar Proxmox image build-proxmox-ubuntu-2204: ## Builds the Proxmox ubuntu-2204 image build-proxmox-ubuntu-2404: ## Builds the Proxmox ubuntu-2404 image build-proxmox-rockylinux-9: ## Builds the Proxmox rockylinux-9 image @@ -1047,6 +1048,7 @@ validate-hcloud-flatcar: ## Validates the Hetzner Cloud Flatcar Packer config validate-hcloud-all: $(HCLOUD_VALIDATE_TARGETS) ## Validates all Hetzner Cloud Packer config validate-proxmox-ubuntu-2204: ## Validates Ubuntu 22.04 Proxmox Packer config +validate-proxmox-flatcar: ## Validates Flatcar Proxmox Packer config validate-vultr-ubuntu-2204: ## Validates Ubuntu 22.04 Vultr Snapshot Packer config diff --git a/images/capi/ansible/roles/providers/tasks/proxmox.yml b/images/capi/ansible/roles/providers/tasks/proxmox.yml index c40d54d33..be3e8f15f 100644 --- a/images/capi/ansible/roles/providers/tasks/proxmox.yml +++ b/images/capi/ansible/roles/providers/tasks/proxmox.yml @@ -60,8 +60,10 @@ ansible.builtin.systemd: name: networkd-dispatcher state: started + when: ansible_os_family == "Debian" - name: Ensure networkd-dispatcher is enabled ansible.builtin.systemd: name: networkd-dispatcher enabled: true + when: ansible_os_family == "Debian" diff --git a/images/capi/packer/proxmox/README.md b/images/capi/packer/proxmox/README.md index 96f45bb15..e3319b2ae 100644 --- a/images/capi/packer/proxmox/README.md +++ b/images/capi/packer/proxmox/README.md @@ -1,11 +1,12 @@ +## Custom Kubernetes version + 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.28.3' --var 'kubernetes_semver=v1.28.3' --var 'kubernetes_series=v1.28' --var 'kubernetes_deb_version=1.28.3-1.1'" make build-proxmox-ubuntu-2204 ``` - -# ISO files +## ISO files To use existing ISO files, set the `ISO_FILE` environment variable to the path of the ISO file. For example, to use a local ISO file, set the `ISO_FILE` environment variable like this: @@ -13,3 +14,29 @@ For example, to use a local ISO file, set the `ISO_FILE` environment variable li ``` export ISO_FILE="local:iso/ubuntu-24.04.1-live-server-amd64.iso" ``` + +## Flatcar for Proxmox + +Currently, Proxmox support is only available in the `alpha` channel of Flatcar. +* https://www.flatcar.org/releases#alpha-release +* https://github.com/coreos/fedora-coreos-tracker/issues/1652 + +Therefore, we need to choose the right channel and version for flatcar along with `OEM_ID=proxmoxve`. + +**To build a Proxmox template for flatcar** + +```shell +export PROXMOX_URL="https://example.net:8006/api2/json" +export PROXMOX_USERNAME='root@pam!proxmox' +export PROXMOX_TOKEN="xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx" +export PROXMOX_NODE="pve1" +export PROXMOX_ISO_POOL="local" +export PROXMOX_BRIDGE="vmbr1" +export PROXMOX_STORAGE_POOL="ceph_pool" + +## flatcar version +export FLATCAR_VERSION=4152.0.0 +export FLATCAR_CHANNEL=alpha + +export OEM_ID=proxmoxve # make sure to choose OEM_ID=proxmoxve +``` diff --git a/images/capi/packer/proxmox/flatcar.json b/images/capi/packer/proxmox/flatcar.json new file mode 100644 index 000000000..64bd2df5f --- /dev/null +++ b/images/capi/packer/proxmox/flatcar.json @@ -0,0 +1,28 @@ +{ + "ansible_extra_vars": "ansible_python_interpreter=/opt/bin/python oem_id={{user `oem_id`}}", + "boot_command_prefix": "sudo systemctl mask sshd.socket --nowcurl -sLo /tmp/ignition.json ", + "boot_command_suffix": "/bootstrap-pass-auth.jsonsed -i \"s|BUILDERPASSWORDHASH|$(mkpasswd -5 {{user `ssh_password`}})|\" /tmp/ignition.jsonsudo flatcar-install -d /dev/sda -C {{user `channel_name`}} -V {{user `release_version`}} -i /tmp/ignition.json && sudo reboot", + "boot_media_path": "http://{{ .HTTPIP }}:{{ .HTTPPort }}", + "boot_wait": "180s", + "build_name": "flatcar-{{env `FLATCAR_CHANNEL`}}-{{env `FLATCAR_VERSION`}}", + "channel_name": "{{env `FLATCAR_CHANNEL`}}", + "crictl_source_type": "http", + "distribution_version": "{{env `FLATCAR_CHANNEL`}}-{{env `FLATCAR_VERSION`}}", + "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", + "unmount_iso": "true" +} diff --git a/images/capi/packer/proxmox/packer.json.tmpl b/images/capi/packer/proxmox/packer.json.tmpl index bb0bdc226..be037a95d 100644 --- a/images/capi/packer/proxmox/packer.json.tmpl +++ b/images/capi/packer/proxmox/packer.json.tmpl @@ -19,6 +19,7 @@ "type": "scsi" } ], + "scsi_controller": "{{user `scsi_controller`}}", "http_directory": "{{user `http_directory`}}", "insecure_skip_tls_verify": true, "iso_checksum": "{{user `iso_checksum_type`}}:{{user `iso_checksum`}}", @@ -72,6 +73,14 @@ "inline_shebang": "/bin/bash -e", "type": "shell" }, + { + "environment_vars": [ + "PYPY_HTTP_SOURCE={{user `pypy_http_source`}}" + ], + "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`}}'", @@ -207,6 +216,7 @@ "token": "{{env `PROXMOX_TOKEN`}}", "username": "{{env `PROXMOX_USERNAME`}}", "vlan_tag": "{{env `PROXMOX_VLAN`}}", - "vmid": "" + "vmid": "", + "scsi_controller": "virtio-scsi-pci" } }