Skip to content

docs(virtualization): guide for building a Windows golden image with Packer - #665

Closed
scooby87 wants to merge 5 commits into
cozystack:mainfrom
scooby87:docs/windows-golden-image
Closed

docs(virtualization): guide for building a Windows golden image with Packer#665
scooby87 wants to merge 5 commits into
cozystack:mainfrom
scooby87:docs/windows-golden-image

Conversation

@scooby87

Copy link
Copy Markdown

What

Adds a Virtualization guide, Building a Windows Golden Image with Packer (content/en/docs/next/virtualization/windows-golden-image.md).

It covers building a customized Windows Server image (Windows + pre-installed software + autologon + RDP) with Packer against the KubeVirt builder, hardening it before capture, and registering the captured disk in Cozystack — either as a cloneable vm-disk (copy-clone) or, for a bare URL-reachable base, via vm-default-images.

Why

Cozystack already documents booting/installing a Windows VM by hand ([Running Windows VMs]) and caching URL-reachable images ([Golden Images]). What was missing is the automated path: baking a customized Windows disk once and cloning many VMs from it. This guide fills that gap.

Notes

  • Placed in next/ per the versioning model; can be copied to current stable versions if desired.
  • Cross-links the existing windows.md, cloneable-vms.md and vm-image.md (all {{% ref %}} targets exist in the same directory).
  • Generic on purpose — no product- or customer-specific content; win2022-iso-dv.yaml, autounattend.xml, harden etc. are described as standard Packer artifacts.
  • Prose follows the one-line-per-paragraph rule; {{% alert %}} blocks kept with blank lines inside so they render and pass the hardwrap check.

…Packer

Add a Virtualization guide covering how to build a customized Windows
Server golden image with Packer against the KubeVirt builder, harden it,
capture the disk, and register it in Cozystack — either as a cloneable
vm-disk (copy-clone) or, for a bare URL-reachable base, via
vm-default-images. Complements the manual "Running Windows VMs" guide
and cross-links Cloneable Virtual Machines and Golden Images.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
@netlify

netlify Bot commented Aug 21, 2026

Copy link
Copy Markdown

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 6c5cec8
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/6a88b00d9ec8b3000837a110
😎 Deploy Preview https://deploy-preview-665--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0d8fec1d-8e80-41c2-a45b-c3642af0ede5


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Alexey Artamonov added 2 commits August 21, 2026 21:30
Expand the Windows golden-image guide with the actual Packer usage:
installing the community KubeVirt builder plugin, a complete
windows.pkr.hcl (source + build with WinRM communicator and provisioners),
the variables file, and the role of autounattend.xml in enabling WinRM
for the build. Previously the guide only showed `packer build` without the
configuration.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
…ric)

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>

@kvaps Andrei Kvapil (kvaps) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Useful addition — the gap is real: windows.md covers installing by hand and vm-image.md covers URL-cached images, and neither describes baking a customized Windows disk once and cloning from it. The framing at the top makes that distinction clear, and I am glad to see the security guidance in a public guide rather than left implicit: harden.ps1 as the mandatory final provisioner, the "never bake credentials or licences" alert, and the evaluation-media caveat (sysprep/spopk.dll, shared SID when generalize is skipped, purchased licence required for production).

I checked the technical claims against the charts and the site. u1.large and windows.2k22.virtio both exist, and all three {{% ref %}} targets (windows.md, vm-image.md, cloneable-vms.md) resolve. Three things need fixing before this lands, though — the first two are things a reader hits immediately.

cloneType: copy is not a knob Cozystack exposes

Use cloneType: copy (not snapshot) so each VM gets an independent disk.

There is no cloneType field in the vm-disk application: the only clone-related value is source.disk.name ("Name of the vm-disk to clone"), and cloneable-vms.md does not mention it either. cloneType is the CDI annotation cdi.kubevirt.io/cloneType on the DataVolume, which a VMDisk author cannot set through the app's values today.

The concern behind the sentence is legitimate and worth keeping — a CSI smart-clone can report Succeeded while leaving the target PVC empty on some storage backends, which is a nasty silent failure. So rather than dropping it, I would state it accurately: describe that cloning goes through CDI, that the clone strategy is chosen by the storage backend, and what to check (or how to force a host-assisted copy) — without implying there is a cloneType value to set in the manifest.

The VMInstance example produces a mis-tuned Windows VM

spec:
  disks:
  - name: windows

instanceProfile defaults to ubuntu and instanceType to u1.medium in the chart, so this example boots Windows with the Ubuntu preference: sata and e1000e instead of virtio, none of the hyperv enlightenments, no TPM or SecureBoot — and, because the Windows node affinity keys off the windows prefix in the profile name, it also opts the VM out of the dedicated-Windows-node scheduling. It contradicts the Packer source above it, which correctly sets preference = "windows.2k22.virtio".

Please set both explicitly in the example, e.g. instanceProfile: windows.2k22.virtio alongside a suitable instanceType.

Step one cannot be completed as written

The plugin section says, correctly, that the KubeVirt builder is a community plugin, not published by HashiCorp, and that packer init cannot resolve it. But the template then keeps source = "github.com/hashicorp/kubevirt" with the advice to "keep the source matching your local install path", and the guide never says where to obtain the plugin — no repository, no build instructions.

As it stands a reader cannot get past the first step, and the hashicorp/ namespace attributes a community plugin to HashiCorp. Either link the actual upstream repository (with the revision it was built against, plus go build and where to drop the binary), or use an unmistakable placeholder such as github.com/<org>/kubevirt and say explicitly that the reader must substitute the plugin they installed.

Smaller

kubectl apply -f win2022-iso-dv.yaml appears in both Prerequisites and Run the build — harmless, but one of the two can go.

…ofile

- Plugin: the KubeVirt builder is the published github.com/hashicorp/kubevirt
  plugin, installed with `packer init` — drop the incorrect "community /
  install manually / cannot packer init" wording and the misattribution.
- Register: describe the CDI-based clone flow (capture a vm-image DataVolume
  in cozy-public, clone per VM via source.image.name, verify it actually has
  data) instead of a non-existent cloneType field.
- VMInstance example: set instanceProfile: windows.2k22.virtio and
  instanceType explicitly, so the VM does not fall back to the ubuntu profile.
- Fix invalid HCL in variables (comma-separated attributes) and remove the
  duplicated ISO DataVolume apply.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
@scooby87

Copy link
Copy Markdown
Author

Thanks for the thorough review — all four addressed in the latest push.

1. `cloneType: copy`. Removed — you are right, it is not a vm-disk value. Rewrote the "register" bullet to describe the actual CDI-based flow (capture the prepared disk into a vm-image-<name> DataVolume in cozy-public, then clone per VM via source.image.name, linking [Cloneable Virtual Machines]). Kept the concern you flagged, stated accurately: the clone strategy is chosen by CDI and the storage backend, and a smart-clone can report Succeeded while leaving the target empty, so the guide now says to verify the DataVolume both reaches Succeeded and actually contains data.

2. Mis-tuned VMInstance. Fixed — the example now sets instanceProfile: windows.2k22.virtio and instanceType: u1.large explicitly, with a note that omitting them falls back to the ubuntu profile (wrong devices, no hyperv/TPM/SecureBoot, opts out of Windows-node scheduling).

3. The plugin step. You were right that the old wording was both wrong and dead-ended — and it turns out the premise was stale: the builder is the published github.com/hashicorp/kubevirt plugin (v0.9.0, provides kubevirt-iso for Linux and Windows). Rewrote the section to install it with packer init (no manual build, no HashiCorp misattribution) and linked the upstream repo and its Windows kubevirt-iso example, which this guide now follows.

4. Smaller. Removed the duplicated kubectl apply -f win2022-iso-dv.yaml; it now appears only under Prerequisites. Also fixed invalid HCL in the variables block (attributes had stray commas).

Ready for another look.

…empty smart-clones

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
@scooby87

Copy link
Copy Markdown
Author

Follow-up on point 1: added the concrete remedy you suggested — if a smart-clone comes up empty, set cdi.kubevirt.io/cloneType: copy on the vm-image-<name> DataVolume to force a host-assisted byte-for-byte copy (fails loudly instead of a silent false-success). Left it as an author-settable annotation on the DataVolume, not a vm-disk field.

@scooby87 scooby87 closed this by deleting the head repository Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants