After creating the cloudbase-init template, you can use it to create new virtual machines. During the creation process, in addition to the usual parameters, you can also configure the initialization data for the newly created virtual machines.
You can create the virtual machines on the AOC management platform, or via the web console, AOC RESTful API or SDK. This section covers configuring the initialization data only. See the "Creating a virtual machine from a template" chapter for full details on creating a virtual machine from a cloudbase-init template.
The methods for creating a virtual machine via the web console and AOC are similar. The following procedure uses AOC as an example.
Log in to AOC to access its homepage. On the upper right corner of the homepage, click Create, and then select Create VM from template to open the Create VM from template dialog box.
In the Create VM from template dialog box, select the cloudbase-init template you created. Then refer to the "Virtual machine configuration options" chapter for details on configuring basic information, computing resources, storage resources and other items for the virtual machine.
When configuring Network device, go to Cloud-init configuration and choose the IP address configuration mode for the virtual machine:
Configure static IP address: Once selected, you need to configure the static IP address and static routing for the virtual machine.
Enable network card DHCP: Once selected, you need to enable DHCP on the virtual machine to get a dynamic IP address.
Not configured: No IP address is configured.
Note:
When the VM network type is
VPC networking
, leaving the IP address blank will disable theConfigure static IP address
option. If you enter an IP address and select theConfigure static IP address
option, the system will automatically configure the virtual machine with the specified static IP address.
In the Initial configuration section, configure the initial data for the virtual machine:
Enter the hostname, default username and password, SSH public key, and DNS server configurations.
Configure the user data. AVE supports up to 32 KB of user data. See User data examples for examples.
Click Create.
Refer to the official cloudbase-init userdata documentation for supported user data.
This section provides examples using User Data Script
and Cloud-Config Runcmd
to configure the user data. Refer to the official documentation for other configurations needed.
User Data Script
Configure Shell Script
as follows so that the virtual machine with cloudbase-init executes the echo "Hello World. The time is now $(date -R)!" >> /root/arcfra.txt
command on its first boot:
#!/bin/sh
echo "Hello World. The time is now $(date -R)!" >> /root/arcfra.txt
Cloud-Config Runcmd
Configure Cloud-Config Runcmd
as follows so that the virtual machine with cloudbase-init executes the curl https://www.arcfra.com/ -o /root/arcfra.html
command on its first boot:
#cloud-config
runcmd:
- [ curl, "https://www.arcfra.com/", -o, /root/arcfra.html ]
You can also create a virtual machine from a cloudbase-init template via the AOC RESTful API or SDK and configure the initialization data for the virtual machine.