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

feat: add ISO support in supervisor builder #501

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dilyar85
Copy link
Contributor

@dilyar85 dilyar85 commented Dec 18, 2024

Description

This PR introduces ISO-based VM deployment support to the vsphere-supervisor builder using the latest v1alpha3 VM Operator APIs. It enables users to:

  • Import an ISO image from a URL.
  • Deploy a VM by mounting the ISO via CD-ROM and attaching a boot disk via PVC.
  • Access the VM's web console through the VirtualMachineWebConsoleRequest CRD for guest OS installation.

For a complete e2e workflow, refer to the Packer builder logs in the testing section below.

Testing

  • Add unit tests for the new ISO VM deployment workflow.
  • Update existing unit tests to reflect the latest v1alpha3 APIs.
  • Verify e2e workflow against an internal testbed with v1alpha3 APIs enabled:
$ packer build -var-file test.json examples/builder/vsphere-supervisor/general-template-with-image-import.pkr.hcl
vsphere-supervisor.vm: output will be in this color.

==> vsphere-supervisor.vm: Creating temporary RSA SSH key for instance...
    vsphere-supervisor.vm: Connecting to Supervisor cluster...
    vsphere-supervisor.vm: Successfully connected to Supervisor cluster
    vsphere-supervisor.vm: Validating VM publish location...
    vsphere-supervisor.vm: VM publish location is valid
    vsphere-supervisor.vm: Validating image import request...
    vsphere-supervisor.vm: Image import configs are valid.
    vsphere-supervisor.vm: Importing the source image from https://packages.<sensitive>.com/photon/3.0/Rev3/iso/Update1/photon-minimal-3.0-913b49438.iso to cl-cd0a143e4b47ced54.
    vsphere-supervisor.vm: Creating ContentLibraryItemImportRequest object packer-vsphere-supervisor-import-req-840f5 in namespace sdiliyaer-test.
    vsphere-supervisor.vm: Successfully created the ContentLibraryItemImportRequest object packer-vsphere-supervisor-import-req-840f5.
    vsphere-supervisor.vm: Waiting for the image import request to complete...
    vsphere-supervisor.vm: Successfully imported the image as a content library item &{"imageregistry.<sensitive>.com/v1alpha1" "ContentLibraryItem" "clitem-8c6d327150e9e9fe3"}.
    vsphere-supervisor.vm: Finished importing the image from https://packages.<sensitive>.com/photon/3.0/Rev3/iso/Update1/photon-minimal-3.0-913b49438.iso to cl-cd0a143e4b47ced54.
    vsphere-supervisor.vm: Creating source objects with name "source-lf9fz" in namespace "sdiliyaer-test"
    vsphere-supervisor.vm: Checking source VM image "vmi-8c6d327150e9e9fe3"
    vsphere-supervisor.vm: Found namespace scoped VM image of type "ISO"
    vsphere-supervisor.vm: Deploying VM from ISO
    vsphere-supervisor.vm: Creating a PVC object for ISO VM boot disk
    vsphere-supervisor.vm: Creating a VM object with PVC and CD-ROM attached
    vsphere-supervisor.vm: Creating a VirtualMachineService object for network connection
    vsphere-supervisor.vm: Finished creating all required source objects
    vsphere-supervisor.vm: Waiting for the source VM to be ready...
    vsphere-supervisor.vm: Use the following network configuration to install the guest OS
    vsphere-supervisor.vm: {
    vsphere-supervisor.vm:     "interfaces": [
    vsphere-supervisor.vm:         {
    vsphere-supervisor.vm:             "name": "eth0",
    vsphere-supervisor.vm:             "ip": {
    vsphere-supervisor.vm:                 "addresses": [
    vsphere-supervisor.vm:                     "192.168.128.5/16"
    vsphere-supervisor.vm:                 ],
    vsphere-supervisor.vm:                 "gateway4": "192.168.1.1"
    vsphere-supervisor.vm:             }
    vsphere-supervisor.vm:         }
    vsphere-supervisor.vm:     ],
    vsphere-supervisor.vm:     "dns": {
    vsphere-supervisor.vm:         "hostName": "source-lf9fz",
    vsphere-supervisor.vm:         "nameservers": [
    vsphere-supervisor.vm:             "192.19.189.10"
    vsphere-supervisor.vm:         ]
    vsphere-supervisor.vm:     }
    vsphere-supervisor.vm: }
    vsphere-supervisor.vm: Generating a web console URL for VM guest OS access...
    vsphere-supervisor.vm: https://192.168.130.1/vm/web-console?host=10.192.76.116&namespace=sdiliyaer-test&port=443&ticket=ee4c92eba9c540f64251788991af33f0&uuid=609c61df-515a-4699-a655-3dd0e7c507b0
    vsphere-supervisor.vm: Use the above URL to complete the guest OS installation.
    vsphere-supervisor.vm: Successfully obtained the source VM IP: 192.168.128.5
    vsphere-supervisor.vm: Getting source VM ingress IP from the VMService object
    vsphere-supervisor.vm: Successfully retrieved the source VM ingress IP: 192.168.130.3
    vsphere-supervisor.vm: Source VM is now ready in Supervisor cluster
==> vsphere-supervisor.vm: Using SSH communicator to connect: 192.168.130.3
==> vsphere-supervisor.vm: Waiting for SSH to become available...
==> vsphere-supervisor.vm: Connected to SSH!
==> vsphere-supervisor.vm: Provisioning with shell script: /var/folders/nf/cndlm4ts2bd9jz3dd667jfb80000gr/T/packer-shell1681540137
    vsphere-supervisor.vm: Publishing the source VM to "cl-cd0a143e4b47ced54"
    vsphere-supervisor.vm: Creating a VirtualMachinePublishRequest object
    vsphere-supervisor.vm: Successfully created the VirtualMachinePublishRequest object
    vsphere-supervisor.vm: Waiting for the VM publish request to complete...
    vsphere-supervisor.vm: Successfully published the VM to image "vmi-65ec97448e3761458"
    vsphere-supervisor.vm: Finished publishing the source VM
    vsphere-supervisor.vm: Skip cleaning up the VirtualMachinePublishRequest object as specified in config
    vsphere-supervisor.vm: Skip cleaning up the source objects as specified in config
    vsphere-supervisor.vm: Deleting the ContentLibraryItemImportRequest object packer-vsphere-supervisor-import-req-840f5 in namespace sdiliyaer-test.
    vsphere-supervisor.vm: Successfully deleted the ContentLibraryItemImportRequest object packer-vsphere-supervisor-import-req-840f5 in namespace sdiliyaer-test.
    vsphere-supervisor.vm: Build 'vsphere-supervisor' finished successfully.
Build 'vsphere-supervisor.vm' finished after 16 minutes 4 seconds.

==> Wait completed after 16 minutes 4 seconds

==> Builds finished but no artifacts were created.

@tenthirtyam tenthirtyam added this to the Backlog milestone Dec 18, 2024
@dilyar85 dilyar85 force-pushed the feat/iso-support branch 2 times, most recently from 5cec440 to c03ef56 Compare December 19, 2024 00:32
@dilyar85 dilyar85 marked this pull request as ready for review December 19, 2024 00:34
@dilyar85 dilyar85 requested a review from a team as a code owner December 19, 2024 00:34
Copy link
Contributor

@ericvmw ericvmw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the change!

if err = s.createVM(ctx, logger); err != nil {
switch imgType {
case "ISO":
logger.Info("Deploying VM from ISO")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Info("Deploying VM from ISO")
logger.Info("Deploying VM from ISO image")

return multistep.ActionHalt
}
case "OVF":
logger.Info("Deploying VM from OVF")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Info("Deploying VM from OVF")
logger.Info("Deploying VM from OVF image")

@tenthirtyam tenthirtyam added the builder/vsphere-supervisor Builder: vsphere-supervisor label Jan 6, 2025
@tenthirtyam tenthirtyam modified the milestones: Backlog, v1.5.0 Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants