- An Azure account
- The Azure CLI installed and configured
- Set environment variables for
- Set optional environment variables
AZURE_LOCATIONto 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.
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.
|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 subnet to use with the virtual network. If the subnet 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 resource group containing the virtual network. If the resource group 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://www.packer.io/docs/other/debugging.html