Provisioning di Fedora CoreOS su Proxmox VE

Prerequisiti

Prima di effettuare il provisioning di una macchina FCOS su Proxmox VE, è necessario disporre di un file di configurazione Ignition contenente le tue personalizzazioni.Se non ne hai uno, consulta la guida creazione di un file ignition.

Devi inoltre avere accesso a un cluster o a un server standalone di Proxmox Virtual Environment (VE) con privilegi amministrativi per creare VM e configurazioni di storage. Tutti i comandi verranno eseguiti come utente root sull’host Proxmox VE.

Configurazione dello storage in Proxmox VE

Prima di effettuare il provisioning delle VM Fedora CoreOS, è necessario creare una posizione di storage dedicata per le immagini FCOS e gli snippet di configurazione Ignition.

Creazione della directory di storage

Per prima cosa, crea una struttura di directory per le risorse di Fedora CoreOS:

mkdir -p /var/coreos

Aggiunta dello storage a Proxmox VE

Aggiungi la nuova directory come posizione di storage in Proxmox VE, in modo che possa contenere sia le immagini delle VM che gli snippet di configurazione:

pvesm add dir coreos --path /var/coreos --content images,snippets

This command creates a new storage location named coreos that Proxmox VE can use for storing disk images and configuration snippets (including Ignition files). For more details on Proxmox VE storage configuration, see the Proxmox VE Storage documentation.

Downloading Fedora CoreOS Images

Fedora CoreOS provides pre-built images specifically optimized for Proxmox VE. You can download these images using either the coreos-installer binary or via a container.

Fetching the QCOW2 image

Fetch the latest image suitable for your target stream (or download and verify it from the web).

STREAM="stable"
# as an installed binary:
coreos-installer download -s $STREAM -p proxmoxve -f qcow2.xz --decompress -C /var/coreos
# or as a container:
podman run --pull=always --rm -v "/var/coreos/images:/data" -w /data \
    quay.io/coreos/coreos-installer:release download -s $STREAM -p proxmoxve -f qcow2.xz --decompress

Both methods will download the latest Fedora CoreOS image for the specified stream (stable, testing, or next) in QCOW2 format, optimized for Proxmox VE. It will store the image in the /var/coreos/images directory.

Preparing Ignition Configuration

Upload your Ignition configuration file to the snippets directory:

# Upload your ignition to /var/coreos/config.ign
scp /path/to/your/config.ign root@proxmoxve-host:/var/coreos/snippets/config.ign

Setting up a new VM

The following example demonstrates how to create and configure a Fedora CoreOS VM using Proxmox VE command-line tools.

Setting Configuration Variables

Define the VM parameters:

VM_ID=101
NAME=fedora-coreos
QCOW=fedora-coreos-{stable-version}-proxmoxve.x86_64.qcow2
IGN=config.ign
STORAGE=local-lvm
CPU=2
MEMORY=2048
DISK_SIZE=90G

Adjust these variables according to your requirements:

  • VM_ID: Unique VM identifier in Proxmox VE

  • NAME: The name for the VM

  • QCOW: Filename of the downloaded FCOS image

  • IGN: Filename of your Ignition configuration

  • STORAGE: Target storage pool for the VM disk

  • CPU: Number of CPU cores to allocate

  • MEMORY: RAM allocation in MB

  • DISK_SIZE: Additional disk space to allocate

Creating and Configuring the VM

Create the VM with the specified configuration:

# Create the initial VM configuration
qm create ${VM_ID} --name ${NAME} --cores ${CPU} --memory ${MEMORY} \
    --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci

# Import the FCOS image as the primary disk
qm set ${VM_ID} --scsi0 "${STORAGE}:0,import-from=/var/coreos/images/${QCOW}"

# Resize the disk to provide additional space
qm resize ${VM_ID} scsi0 +${DISK_SIZE}

# Add cloud-init drive for configuration delivery
qm set ${VM_ID} --ide2 ${STORAGE}:cloudinit

# Set boot order to use the imported disk
qm set ${VM_ID} --boot order=scsi0

# Configure serial console for better compatibility
qm set ${VM_ID} --serial0 socket --vga serial0

# Configure Ignition file delivery via cloud-init
qm set ${VM_ID} --cicustom vendor=coreos:snippets/${IGN}

# Disable automatic upgrades during provisioning
qm set ${VM_ID} --ciupgrade 0

Network Configuration

DHCP Configuration

The basic VM creation above uses DHCP for network configuration, which is suitable for most environments where dynamic IP assignment is acceptable.

Static IP Configuration

For environments requiring static IP addresses, configure the network settings:

# For static IP address
IP="192.168.1.100"
IP_CIDR="${IP}/24"
GATEWAY="192.168.1.1"
qm set ${VM_ID} --ipconfig0 ip=${IP_CIDR},gw=${GATEWAY}

Replace the IP addresses with values appropriate for your network configuration.

Booting and Accessing the VM

Starting the VM

Start the VM and access its console:

# Start and wait for the VM to start
qm start ${VM_ID}

Exploring the OS

You log into the VM from the host with the following command:

# Access the VM console from the host
qm terminal ${VM_ID}

If you set up an SSH key for the default core user, you can SSH into the VM via the IP address:

ssh core@<indirizzo ip>

Clean up

For testing purposes, you can easily clean up the VM:

# Stop the VM
qm stop ${VM_ID}

# Remove the VM and its associated storage
qm destroy ${VM_ID}