Skip to content

Conversation

happy-game
Copy link
Contributor

@happy-game happy-game commented Aug 15, 2025

目的

Cloudpods 目前支持创建虚机并且挂载 ISO 镜像,但不支持虚机启动时通过 kickstart 自动化安装 ISO 镜像。需要开发支持创建虚机流程中注入 kickstart 脚本到 cloudpods 元数据中,启动虚机时添加 kickstart 自动化安装 ISO 镜像相关 QEMU 参数,并且兼容主流的操作系统。

关联

OSPP项目

开发要求

  1. 虚拟机启动能够触发 kickstart 自动化安装 ISO 镜像。
  2. 通过 Cloudpods API/CLI 注入或者更新 Kickstart 配置。
  3. 兼容主流 Linux 发行版(CentOS/RHEL, Fedora, Ubuntu 等)。
  4. 代码以 PR 形式提交到 https://github.com/yunionio/cloudpods 仓库。
  5. 产出项目开发使用文档。

开发进度

  • 1. 拓展创建虚拟机的API
    • 新增 kickstart 相关参数
    • 新增 kickstart 相关 metadata
    • 新增相关 CLI 命令
    • 修改前端界面
  • 2. 实现 kickstart 自动化安装
    • 需要 kickstart 时在创建虚拟机时挂载安装镜像到 /tmp 文件夹
    • 实现自动化安装
      • CentOS
      • Ubuntu
      • Fedora
      • RHEL
    • 通过 URL 传递 kickstart 参数
    • 以文件/文本形式传递 kickstart 参数
    • 安装结束自动更新自动化安装状态
    • 在生命周期结束时卸载镜像
    • 在自动安装成功后重启虚拟机
  • 3. 多系统版本测试
  • 4. 提供示例及文档

- Add kickstart-related parameters to `/servers`
- Implement basic validation
- Add corresponding options for server creation via climc
- Add `GetDetailsKickstart` to query configuration
- Add CLI commands to set, get, and delete kickstart configurations
The kickstart process requires extracting kernel files (e.g., `initrd`,
`vmlinuz`) from the ISO to customize QEMU boot parameters. This change
mounts the ISO to a temporary directory to enable this.

Cleanup of the temporary mount directory is also needed, but is not
implemented yet and is planned for a future update.
Add kickstart automation support for VM creation with the following steps:
1. Mount installation ISO to /tmp directory
2. Use initramfs and vmlinuz from mount path for qemu args
3. Inject kernel boot parameters with autoinstall configuration
4. Start VM to execute automated installation

Modified `guestLauncher` script to handle kernel parameters with spaces
that were previously truncated by the Python script.
Add serial port monitoring to host component for tracking
Kickstart auto-installation status. Guest VMs can send status
messages to host via `/dev/ttyS0` for Kickstart status synchronization.
Monitor automatically starts when VM metadata indicates kickstart
status is 'pending' or 'installing'.
Automatically update status when kickstart monitor
recive `KICKSTART_(SUCCESS|FAILED)`
- Remove function MountISOToTmp used only here, inline the logic
- Change mount point to /tmp/kickstart-iso-%ISO_ID
- Reuse existing mount if already mounted
- Unmount mount points used for kernel and initramfs
- Restart server via Region API

Avoid using QMP restart as it's an internal VM restart that doesn't regenerate qemu parameters through cloudpods startup flow, which would trigger auto-installation again
@happy-game happy-game force-pushed the feature/implement-autoinstall branch from 02cc7dc to d6be91b Compare August 21, 2025 02:03
Create dedicated serial log files in /tmp for Kickstart instead of
using /dev/pts/xx. Using /dev/pts/xx causes the host to receive SIGHUP
and stop when the master end of the serial port terminates(VM stop).
@happy-game happy-game force-pushed the feature/implement-autoinstall branch from ba26f17 to 9d5553a Compare August 21, 2025 15:40
Adds the `VM_METADATA_KICKSTART_TYPE` to distinguish between
kickstart configurations passed by URL or by direct content.
- Set status to installing when machine successfully boots for kickstart
- Handle KICKSTART_INSTALLING serial message to update status
- Add size limits for kickstart config content (64KB) and URL (2KB)
- Validate URL content size validation via HTTP HEAD request (64KB)
- Add URL format validation (HTTP/HTTPS schemes only)
Embed the provided config content as a file in a
labeled ISO (mkisofs), then mount the ISO during
the Kickstart installation to supply the config.
This commit integrates Kickstart state management into the
VM status instead of the previous metadata-based approach,
with the following changes:

- add VM_KICKSTART_* and VM_KICKSTART_STATUS to manage kickstart status
- remove kickstart status related metadata
- add kickstart_completed_flag metadata, skip when completed flag is set;
- set kickstart_installing and start serial monitor on boot
- switch KICKSTART_SUCCESS to KICKSTART_COMPLETED
Place the configuration ISO and the temporary
mount for extracting the kernel and initramfs
images into /tmp/kickstart/$server_id/
@happy-game happy-game force-pushed the feature/implement-autoinstall branch from ed0cc81 to a137316 Compare September 12, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants