proxmox of cloud-init

Cloud-Init support

Cloud-Init is the de facto pay would contract it early initialization process virtual machine instance. Use Cloud-Init, and can configure network devices ssh key hypervisor end. When a VM is first started, Cloud-Init software within the VM to apply these settings.

Many Linux distributions offer a ready-to-Cloud-Init images, primarily for OpenStack design . These images also apply to Proxmox VE. While ready-to-obtain such images look very easy, but we usually recommend that you prepare your own image. The advantage is that you will know exactly the content of installed, which will help you later to easily customize the image to suit your needs.

After creating such a Cloud-Init images, we recommend that convert it to a VM template. VM from a template, you can quickly create a linked clone, so this is a quick way to launch a new VM instance. You only need to configure the network (possibly ssh key) before starting the new VM.

We recommend using SSH key-based authentication logon Cloud-Init configured VM. You can also set a password, but it is better to use SSH key-based security verification of identity, because Proxmox VE need to store an encrypted version of the password in the Cloud-Init data.

Proxmox VE ISO image to the Cloud-Init data to the VM. To this end, all Cloud-Init VM need to have a specified CDROM drive. In addition, many Cloud-Init image has assumed a serial console, it is proposed to add a serial console and used as the VM monitor.

Cloud-Init templates ready

The first step is to prepare VM. Basically you can use any VM. Just install the Cloud-Init package can be prepared in the VM. On a system based on Debian / Ubuntu, it is very simple:

apt-get install cloud-init

Many distributions already provides a ready Cloud-Init image (to .qcow2 file form provided ), so you can simply download and import the images. For the following example, we will use the Ubuntu cloud images provided, the URL for the https://cloud-images.ubuntu.com .

Photo # 
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img 

# create a new VM 
qm the Create 9000 --memory 2048 --net0 virtio, Bridge = vmbr0 

# downloaded disk introduced local-lvm store 
QM 9000 Bionic importdisk-Server-cloudimg-amd64.img local-lvm 

#finally VM new disk to a drive scsi 
qm set 9000 --scsihw virtio-scsi- pci --scsi0 local-lvm: vm-9000- disk-1
  Ubuntu Cloud-Init image requires virtio-scsi-pci  controller for the type of SCSI drives.
Add Cloud-Init CDROM drive

The next step is to configure the CDROM drive, the drive will be used to transfer data to the Cloud-Init VM.

qm set 9000 --ide2 local-lvm:cloudinit

Cloud-Init to be able to boot from the images, set directly bootdisk parameter set  to as scsi0 , and is limited to only disk BIOS boot. This will speed up the startup speed, because the VM BIOS will skip bootable CDROM tests.

qm set 9000 --boot c --bootdisk scsi0

Also configure the serial console and used as a display. Cloud-Init Many rely on this image, as it is required OpenStack image.

qm set 9000 --serial0 socket --vga serial0

In the final step, converting the VM template helpful. Then, you can quickly create a template from a linked clone. Deployment is much faster than from the VM template to create a complete clone (copy).

qm template 9000

Deployment of Cloud-Init template

You can easily deploy these templates by cloning:

qm clone 9000 123 --name ubuntu2

Then configure SSH public key for authentication, and configure the IP settings:

~ qm provided --sshkey 123 / .ssh / id_rsa.pub 
qm = 10.0.10.123 IP --ipconfig0 SET 123/24, GW = 10.0.10.1

You can also use only one command to configure all Cloud-Init option. We split the above examples simply to reduce the line length of the command separator. Also, make sure you use IP settings for your specific environment.

Cloud-Init-specific options

cicustom[meta = <volume>] [,network = <volume>] [,user = <volume>]

To replace the specified file definition file generated automatically at the beginning of self.

meta = <volume>

Specifies contains a custom file is passed to the VM by cloud-init all metadata. This is a different provider specific meaning configdrive2 and nocloud.

network = <volume>

Specifies file contains all of the custom network data passed to the VM by cloud-init.

user = <volume>

Specifies the customization file contains all the user data is passed to the VM by cloud-init.

cipassword<string>

Assign the user's password. Generally not recommended to use it. Instead, use the ssh key. Please also note that older versions do not support cloud-init hashed password.

citype<configdrive2 | nocloud>

Cloud-init configuration specified format. The default value depends on the type of operating system configurations ( OSTYPE . We use Linux  in nocloud format and the Windows configdrive2 .

ciuser<string>

Ssh key is used to change the user name and password, instead of the image of the default user configuration.

ipconfig [n][gw = <GatewayIPv4>] [,gw6 = <GatewayIPv6>] [,ip = <IPv4Format / CIDR>] [,ip6 = <IPv6Format / CIDR>]

Corresponding to the specified IP address and gateway interfaces.

CIDR notation IP address, the gateway is optional, but need to specify the same type of IP.

Special string dhcp available for IP addresses using DHCP, in this case, should not provide explicit gateway. For IPv6, special string auto available for use stateless autoconfiguration.

If the cloud-init enabled and neither specified nor IPv6 IPv4 address is specified, the default is to use dhcp on IPv4.

gw = <GatewayIPv4>

The default gateway IPv4 traffic.

  Require option: ip
gw6 = <GatewayIPv6>

Default Gateway IPv6 traffic.

  Require option: ip6
IP  =  <IPv4Format / CIDR> ( Default =  DHCP )

IPv4 addresses in CIDR format.

IP6  =  <IPv6Format / CIDR> ( Default =  DHCP )

CIDR IPv6 address format.

nameserver<string>

Set the container's DNS server IP address. If neither the searchdomain not set nameserver, Create will automatically set the host.

searchdomain<string>

DNS search domains, setting the containers. If neither the searchdomain not set nameserver, Create will automatically set the host.

sshkeys<string>

SSH public key is provided (one per line key, OpenSSH format).

Guess you like

Origin www.cnblogs.com/surplus/p/11432861.html