Openstack electronic bare metal Practice 2 disk startup

I wrote an article about openstack iron bare metal operation before, which mainly introduces the state machine of iron and the introduction of issuing memory operating system with iron. Interested friends can refer to:

Openstack electronic bare metal Practice

In this article, I want to talk about the operation of lowering the image and starting from the hard disk with Ironic.

Ironic is an Openstack component, which is responsible for managing bare metal machines. Most commands are automatically delegated through Openstack, so it is not easy to understand the principle.

But in fact, Ironic itself is a relatively independent component, which supports independent command operation. However, because the relevant documents do not give enough demo s, and there are many command parameters, it is not easy to find the correct command parameters.

After a period of debugging, I recorded relevant commands and shared them for the convenience of friends in need.

Operation:

  • The first is to register bare metal information
    baremetal node create --driver ipmi \
    	--driver-info deploy_kernel=http://http_ip:http_port/ironic-python-agent.kernel \
    	--driver-info deploy_ramdisk=http://http_ip:http_port/ironic-python-agent.initramfs \
        --driver-info ipmi_address=ipmi_ip \
    	--driver-info ipmi_port=ipmi_port \
        --driver-info ipmi_username=ipmi_username \
        --driver-info ipmi_password=ipmi_password \
    	--property  boot_mode=bios \
    	--property  vendor=unknown \
    	--deploy-interface direct \
        --boot-interface ipxe \
    	--name node_0

    http_ip and http_port: the IP and port that provides the image download service

    ironic-python-agent.key/initramfs: it is the official image of Irnoic. It cooperates with clean and inspect

    ipmi_ip/ipmi_username/ipmi_password: IPMI information set on bare metal

After the above command is successful, a UUID information of node will be returned. The UUID should be used repeatedly in the future.

You can also view the UUID information of node through the following command:

baremetal node list

 

After entering the information, the bare metal machine is in the enroll state

  • Create bare metal port:

baremetal port create --node  node_uuid node_mac_address
node_uuid: the uuid generated when the node is created

node_mac_address: MAC address of the bare metal network card; If there are multiple network cards on the bare metal, enter the network card connected to the IC Pxe service; (Pxe is simply used to download images. Please refer to my related articles)

  • Agmanable status:

Managable, as the name suggests, means manageable. It triggers Ironic to check the bare metal IPMI (out of band management, operation restart) function. After passing the check, it enters the managable state;

baremetal node manage node_uuid

managable indicates that the inspection is complete

If there is a problem with this step, refer to the inspection method Openstack electronic bare metal Practice

  • Clean bare metal

It is also mentioned in the chapter of Ironic state machine that after the bare metal machine is registered, it should be cleaned up and put into the resource pool before it is provided to customers for use; That is, the bare metal cleaning is triggered to enter the available state

baremetal node provide node_uuid
Wait for the bare metal machine to download the image and clean it up. After cleaning up, it will enter the available state

  • Set image information
baremetal node set node_uuid   \
--instance-info image_disk_format=qcow2 \
--instance-info image_source=http://http_ip:http_port/ubuntu-image.qcow2 \
--instance-info image_os_hash_algo=md5 \
--instance-info image_os_hash_value=http://http_ip:http_port/ubuntu-image.qcow2.md5 \
--instance-info image_checksum=http://http_ip:http_port/ubuntu-image.qcow2.md5 \
--instance-info image_url=http://http_ip:http_port/ubuntu-image.qcow2 \
--instance-info image_type=whole-disk-image \
--instance-info configdrive='{"meta_data": {"public_keys": {"0": "ssh key contents"}}}'

Parameter Ubuntu image Qcow2 is the image file generated by the openstack tool disk image create. The use of this tool will be described below.

ubuntu-image.qcow2.md5 is Ubuntu image The md5 value of qcow2 can be generated together when disk image create creates an image file.

configdriver can not be set. It is used to provide system initialization parameters. Interested friends can learn by themselves.

  • Set disk startup information
baremetal node set node_uuid \
--property  boot_mode=bios \
--property  root_device='{"name": "s== /dev/vda"}' \
--property  cpu_arch=x86_64


root_ The device parameter is very important. This parameter sets the path of a disk to which the system file (qcow2) will be written.

  • Deploy bare metal
baremetal node deploy node_uuid

Inform Ironic to start deploying corresponding bare metal machines; Query and wait for deployment to complete; After completion, the bare metal will enter the active state; ubuntu-image. The qcow2 file will be written to the specified disk of the bare metal and started.

  • Reclaim bare metal:

If the bare metal machine is no longer used, you can recycle it with this command

baremetal node undeploy node_uuid

If you want to delete bare metal:

baremetal node delete node_uuid
  • Create Image

This section describes how to create a qcow2 file. Use the disk image create tool

Install disk image create

pip install diskimage-builder

Make image

export DIB_DEV_USER_USERNAME="ironic"  #Set user name
export DIB_DEV_USER_PWDLESS_SUDO=Yes   
export DIB_DEV_USER_PASSWORD=123       #Set password

isk-image-create ubuntu vm baremetal devuser dhcp-all-interfaces --checksum -o ubuntu-image --image-size 25

ubuntu description is based on ubuntu image, or other systems such as centos can be selected

--The checksum parameter generates an md5 file

If a node needs debugging during packaging, you can set the environment variable

export break=before-pre-install

After the command is executed, you can get the corresponding qcow2 file

Keywords: Kubernetes OpenStack

Added by Kryllster on Tue, 04 Jan 2022 14:42:20 +0200