Packer
Kingsoft Cloud
@kingsoftcloud
The Kingsoft Cloud plugin can be used with HashiCorp Packer to create custom images on Ksyun.
- Community
Updated 10 months ago
- GitHub(opens in new tab)
Ksyun EPC
Type: ksyun-epc
The ksyun-epc
Packer builder is able to create Ksyun Images backed by
bare metal instance storage as the root device.
Configuration Reference
There are many configuration options available for the builder. In addition to the items listed here, you will want to look at the general configuration references for Image, Access, Run and General configuration references, which are necessary for this build to succeed and can be found further down the page.
Run Configuration
Required:
host_type
(string) - Machine type of epc. Valid Options: see the HostType of epc informationsource_image_id
(string) - Source image id whose root volume will be copied and provisioned on the currently running instance.
Optional:
raid
(string) - Data Disk Raid level. Valid options:Raid1
,Raid5
,Raid10
,Raid50
andSRaid0
, the details see the Raid of epc informationnetwork_interface_mode
(string) - Network interface mode. Valid options:bond4
,single
anddual
.host_name
(string) - The name of epc host. Default value:ksc_epc
.computer_name
(string) - The system name of this epc computer.host_charge_type
(string) - Host Charge Typesecurity_agent
(string) - Security component type. Valid options:classic
andno
.container_agent
(string) - Container engine component type. Valid options:supported
andunsupported
, Defaultunsupported
.cloud_monitor_agent
(string) - The monitor agent.system_file_type
(string) - The system disk file type. Valid options:EXT4
andXFS
. DefaultEXT4
.data_file_type
(string) - The Data disk file type. Valid options:EXT4
andXFS
. DefaultEXT4
.data_disk_catalogue
(string) - The catalogue of data disk. Valid options:/DATA/disk
and/data
. Default/data
.data_disk_catalogue_suffix
(string) - The suffix of data disk catalogue.NoSuffix
: creating data disk catalogue without suffix, but it's valid, when there is one data disk.NaturalNumber
: creating data disk catalogue with suffix that increment from 1.NaturalNumberFromZero
: creating data disk catalogue with suffix that increment from 0. Valid options:NoSuffix
,NaturalNumber
andNaturalNumberFromZero
. DefaultNaturalNumber
extension_subnet_id
(string) - The subnet id of secondary network interfaceextension_subnet_name
(string) - The subnet name of secondary network interfaceextension_subnet_cidr_block
(string) - The subnet cidr block of secondary network interface.extension_private_ip_address
(string) - The private ip address under the vpc of secondary network interface.extension_dns1
(string) - The address of first dns server.extension_dns2
(string) - The address of second dns server.extension_security_group_id
(string) - Extension Security Group Idextension_security_group_name
(string) - Extension Security Group Name
Access Configuration
Required:
access_key
(string) - Ksyun access key must be provided unlessprofile
is set, but it can also be sourced from theKSYUN_ACCESS_KEY
environment variable.secret_key
(string) - Ksyun secret key must be provided unlessprofile
is set, but it can also be sourced from theKSYUN_SECRET_KEY
environment variable.region
(string) - Ksyun region must be provided unlessprofile
is set, but it can also be sourced from theKSYUN_REGION
environment variable.
General Configuration
Optional:
vpc_id
(string) - VPC ID allocated by the system.vpc_name
(string) - the default value is packer_vpcvpc_cidr_block
(string) - 172.16.0.0/16. When not specified, the default value is 172.16.0.0/16.subnet_id
(string) - The ID of the Subnet to be used.subnet_name
(string) - the default value is packer_subnetdns1
(string) - 172.16.0.0/24. When not specified, the default value is 172.16.0.0/24.dns2
(string) - DNS 2subnet_cidr_block
(string) - Subnet Cidr Blockavailability_zone
(string) - availability_zonesecurity_group_id
(string) - ID of the security group to which a newly created instance belongs. Mutual access is allowed between instances in one security group. If not specified, the newly created instance will be added to the default security group. If the default group doesn’t exist, or the number of instances in it has reached the maximum limit, a new security group will be created automatically.security_group_name
(string) - The security group name. The default value is blank. [2, 128] English or Chinese characters, must begin with an uppercase/lowercase letter or Chinese character. Can contain numbers, ., _ or -. It cannot begin withhttp://
orhttps://
. the default value is packer_security_groupprivate_ip_address
(string) - Private IP address, which specifies any valid value within the range of subnet IP address and represents the primary IP address of the instance. Only one can be selected and bound to the primary network card. If this parameter is not specified, the system will automatically select one from the valid address pool at random Valid values: standard IP address formatassociate_public_ip_address
(bool) - Indicating associate whether public ip for creating kec instance Defaultfalse
public_ip_charge_type
(string) - PublicIp charge type, which can be Daily TrafficMonthly DailyPaidByTransfer HourlyInstantSettlement Default is Dailypublic_ip_band_width
(int) - [1-100] Default is 1project_id
(string) - Default is 0run_tags
(map[string]string) - Key/value pair tags to apply to the instance that is launched to create the image. These tags are not applied to the resulting image.run_tag
([]{key string, value string}) - Same asrun_tags
but defined as a singular repeatable block containing akey
and avalue
field. In HCL2 mode thedynamic_block
will allow you to create those programatically.
Image Configuration
Optional:
image_name
(string) - The name of the user-defined image, [2, 64] English or Chinese characters. It must begin with an uppercase/lowercase letter or a Chinese character, and may contain numbers,_
or-
. It cannot begin withhttp://
orhttps://
.
Basic Example
Here is a basic example. It is completely valid but excludes the access keys:
Example Usage
{
"variables": {
"access_key": "{{ env `KSYUN_ACCESS_KEY` }}",
"secret_key": "{{ env `KSYUN_SECRET_KEY` }}"
},
"builders": [{
"type":"ksyun-epc",
"access_key":"{{user `access_key`}}",
"secret_key":"{{user `secret_key`}}",
"region":"cn-beijing-6",
"source_image_id":"eb8c0428-476e-49af-8ccb-9fad2455a54c",
"host_type":"EC-I-III-II",
"availability_zone":"cn-beijing-6c",
"raid": "Raid1",
"ssh_username":"root",
"ssh_clear_authorized_keys": true,
"associate_public_ip_address": true
}],
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
"yum install mysql -y"
]
}]
}