- An Azure account
- The Azure CLI installed and configured
- Set environment variables for
- Set optional environment variables
GALLERY_NAMEto override the default values
The build prerequisites for using
building Azure images are managed by running:
images/capi directory, run
images/capi directory, run
If building the Windows images from a Mac there is a known issue with connectivity. Please see details on running macOS with ansible.
Most of the images built from the
images/capi directory for Azure will be Hyper-V Generation 1 images. There are also a few available configurations to build Generation 2 VMs. The naming pattern is identical to Generation 1 images, with
-gen2 appended to the end of the image name. For example:
# Generation 1 image make build-azure-sig-ubuntu-1804 # Generation 2 image make build-azure-sig-ubuntu-1804-gen2
Generation 2 images may only be used with Shared Image Gallery, not VHD.
Confidential VMs require specific generation 2 OS images. The naming pattern of those images includes the suffix
-cvm. For example:
# Ubuntu 20.04 LTS for Confidential VMs make build-azure-sig-ubuntu-2004-cvm # Windows 2019 with containerd for Confindential VMs make build-azure-sig-windows-2019-containerd-cvm
This table lists several common options that a user may want to set via
PACKER_VAR_FILES to customize their build behavior. This is not an exhaustive
list, and greater explanation can be found in the
Packer documentation for the Azure ARM builder.
|Use image from a Community gallery as a base image instead of default one from the marketplace. Depending on the target distro, fields like |
|Use image from Directly shared gallery as a base image instead of default one from the marketplace. Depending on the target distro, fields like |
|This value allows you to set a virtual_network_name and obtain a public IP. If this value is not set and virtual_network_name is defined Packer is only allowed to be executed from a host on the same subnet / virtual network.|
|Use a pre-existing virtual network for the VM. This option enables private communication with the VM, no public IP address is used or provisioned (unless you set private_virtual_network_with_public_ip).|
|If virtual_network_name is set, this value may also be set. If virtual_network_name is set, and this value is not set the builder attempts to determine the resource group containing the virtual network. If the resource group cannot be found, or it cannot be disambiguated, this value should be set.|
|If virtual_network_name is set, this value may also be set. If virtual_network_name is set, and this value is not set the builder attempts to determine the subnet to use with the virtual network. If the subnet cannot be found, or it cannot be disambiguated, this value should be set.|
If you are adding features to image builder than it is sometimes useful to work with the images directly. This section gives some tips.
After creating a VHD, create a managed image using the url output from
make build-azure-vhd-<image> and use it to create the VM:
az image create -n testvmimage -g cluster-api-images --os-type <Windows/Linux> --source <storage url for vhd file> az vm create -n testvm --image testvmimage -g cluster-api-images
There are several ways to debug Packer scripts: https://developer.hashicorp.com/packer/docs/debugging