Found 0 result in total
Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-08-04 11:26:30
You can create custom images based on instances that can run normally. The instances must be in the Running or Stopped state.
You can create custom images based on existing instances or snapshots. These images can be used to quickly replicate the system environment, saving the need of repeated configuration.
At present, 50 custom images are supported in each region.
To ensure that a custom image can be used normally, you must fulfill the following tasks before you create the image:
To create a Linux image, you must delete or comment out the mount information you have added in the /etc/fstab
configuration file, and retain only the mount information that comes with the system.
To create a Windows image, you must enable the DHCP ports (UDP 67 and UDP 68) on the Windows firewall by using the following commands:
netsh advfirewall firewall set portopening udp 67 enable
netsh advfirewall firewall set portopening udp 68 enable
Or
netsh firewall set portopening udp 67 enable
netsh firewall set portopening udp 68 enable
Log in to the KEC console. The Instance page appears by default.
In the instance list, find the instance from which you want to create an image and choose More > Create Image in the Operation column.
In the dialog box that appears, set the Instance Type parameter and add data disks based on your business requirements. Common images and local images are supported. The images are stored in different locations:
After the image is created, you can view and manage the image on the Image page.
You can use a custom image to create an instance or reinstall the operating system. You can use a local image in the corresponding region to create only an instance that uses SSD EBS 3.0 as the system disk or reinstall the operating system for such an instance.
Log in to the KEC console. In the left navigation pane, choose Snapshot > Snapshot List.
Find the snapshot from which you want to create an image and click Create Image in the Operation column. When you create an image, you can decide whether to add data disks based on your business requirements. If you select a local snapshot as the system disk snapshot, the type of data disk snapshots can only be local snapshot and the created custom image is a local image. If you select a common snapshot as the system disk snapshot, the type of data disk snapshots can only be common snapshot and the created custom image is a common image.
After the image is created, you can view and manage the image on the Image page.
You can use a custom image to create an instance or reinstall the operating system.
Packer is a lightweight image tool that supports mainstream operating systems, such as Windows, Linux, and macOS. This section describes how to use Packer to create custom images.
$GOPATH/src/github.com/kingsoftcloud/packer-plugin-ksyun
directory.
$ mkdir -p $GOPATH/src/github.com/kingsoftcloud;
$ cd $GOPATH/src/github.com/kingsoftcloud
$ git clone git@github.com:kingsoftcloud/packer-plugin-ksyun.git
$ cd $GOPATH/src/github.com/kingsoftcloud/packer-plugin-ksyun
$ make build
$ln -s $GOPATH/bin/packer-plugin-ksyun ~/.packer.d/plugins/packer-plugin-ksyun
To use Packer to create a custom image, you must create a template file in the JSON format. In the template file, you must specify the builder and provisioner for creating the custom image.
The following is a sample template file, which can be found in the example
directory.
{
"variables": {
"access_key": "{{ env `KSYUN_ACCESS_KEY` }}",
"secret_key": "{{ env `KSYUN_SECRET_KEY` }}"
},
"builders": [{
"type":"ksyun-kec",
"access_key":"{{user `access_key`}}",
"secret_key":"{{user `secret_key`}}",
"region":"cn-shanghai-2",
"image_name":"packer_test",
"source_image_id":"IMG-dd1f8324-1f27-46e0-ad6b-b41d8c8ff025",
"instance_type":"N3.1B",
"ssh_username":"root",
"associate_public_ip_address": true
}],
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
"yum install mysql -y"
]
}]
}
The following table describes the parameters that you need to customize.
Parameter | Description |
---|---|
access_key | Your AccessKey ID. |
secret_key | Your AccessKey secret. |
region | The region of temporary resources that are used to create the custom image. |
image_name | The name of the custom image. |
source_image_id | The ID of the base image. |
instance_type | The type of the temporary instance that is created when you create the custom image. |
provisioners | The Packer provisioner that is used to create the custom image. |
export KSYUN_ACCESS_KEY=<Your AccessKey ID>
export KSYUN_SECRET_KEY=<Your AccessKey secret>
packer build example/ksyun.json
Pure Mode