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 flatcar build for Proxmox #1589

Open
wants to merge 7 commits 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
4 changes: 3 additions & 1 deletion images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions images/capi/ansible/roles/providers/tasks/proxmox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
31 changes: 29 additions & 2 deletions images/capi/packer/proxmox/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
## 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:

```
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
```
28 changes: 28 additions & 0 deletions images/capi/packer/proxmox/flatcar.json
Original file line number Diff line number Diff line change
@@ -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 --now<enter><wait>curl -sLo /tmp/ignition.json ",
"boot_command_suffix": "/bootstrap-pass-auth.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 && sudo reboot<enter>",
"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"
}
12 changes: 11 additions & 1 deletion images/capi/packer/proxmox/packer.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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`}}",
Expand Down Expand Up @@ -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`}}'",
Expand Down Expand Up @@ -207,6 +216,7 @@
"token": "{{env `PROXMOX_TOKEN`}}",
"username": "{{env `PROXMOX_USERNAME`}}",
"vlan_tag": "{{env `PROXMOX_VLAN`}}",
"vmid": ""
"vmid": "",
"scsi_controller": "virtio-scsi-pci"
}
}