image-builder icon indicating copy to clipboard operation
image-builder copied to clipboard

CAPI ova: need ability to customize OVF metadata

Open codenrhoden opened this issue 5 years ago • 6 comments
trafficstars

Downstream consumers of the image-builder for CAPI that building OVAs may have a need to customize the metadata included in the OVF. It's time to take a look at what is currently in the metadata, and an a generic way to customize the metadata.

This is all done in the Packer post-processing step.

/assign

codenrhoden avatar Feb 13 '20 16:02 codenrhoden

@codenrhoden

For the OS type and description to be correct, I had to include the ovf:id and vmw:osType before vSphere would recognize it.

For example from: https://github.com/kubernetes-sigs/image-builder/blob/39ef2696339a8fa0a4f55030a77002a316e224e6/images/capi/hack/image-build-ova.py#L201

to:

    <OperatingSystemSection ovf:id="${OS_ID}" vmw:osType="${OS_TYPE}">

Pass through from the ova-<osname>.json to image-build-ova.py here.

   # Create the OVF file.
    ovf = "%s.ovf" % build['name']
    create_ovf(ovf, {
        'BUILD_DATE': build_data['build_date'],
        'BUILD_NAME': build['name'],
        'ARTIFACT_ID': build['artifact_id'],
        'BUILD_TIMESTAMP': build_data['build_timestamp'],
        'OS_NAME': build_data['os_name'],
        'OS_TYPE': build_data['os_type'],
        'OS_ID': build_data['os_id'],
        'ISO_CHECKSUM': build_data['iso_checksum'],
        'ISO_CHECKSUM_TYPE': build_data['iso_checksum_type'],
        'ISO_URL': build_data['iso_url'],
        'POPULATED_DISK_SIZE': vmdk['size'],
        'STREAM_DISK_SIZE': vmdk['stream_size'],
        'VMX_VERSION': args.vmx_version,
    })

For Photon: ovf:id="36" vmw:osType="vmwarePhoton64Guest"

MnrGreg avatar Mar 12 '20 01:03 MnrGreg

For the OS type and description to be correct, I had to include the ovf:id and vmw:osType before vSphere would recognize it.

Ha, thanks for the pointer @MnrGreg ! You must have had a sense that I was working on that very same problem as you wrote that. I learned the same thing just a few hours before your comment. In fact, I opened a PR last night that does that very thing.

I also learned that for some OS's, just setting ovf:id and vmw:oType is not enough. For CentOS 7, for example, you also need to set ovf:version="7" to show up as CentOS 7 rather than thinking it's version 5 and below.

And on top of that, when building Photon, if I set the os_type to vmwarePhoton64Guest and did the build, the hypervisor would choke on it and fail to start the VM. I had to set it to vmware-photon-64 for the hypervisor, but then translate that to vmwarePhoton64Guest in the OVF. Fun times, fun times..

End result was this commit: https://github.com/kubernetes-sigs/image-builder/commit/3cbdb00f230b92ef2f160e7e45b90dc6708ad21f

codenrhoden avatar Mar 12 '20 15:03 codenrhoden

Oh nice work! I didn’t know about ovf:version, that might be the reason for some of our inconsistencies.

MnrGreg avatar Mar 13 '20 04:03 MnrGreg

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Jun 11 '20 04:06 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Jul 11 '20 05:07 fejta-bot

/lifecycle frozen

This will be tackled as a converter within the CLI

codenrhoden avatar Jul 22 '20 17:07 codenrhoden