openstack-裸金属ironic创建及调度-2

创建裸金属实例Flavor

官方文档https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html

在 Queen 版本中,Ironic 项目新增 Trait API,节点的 traits 信息可以注册到计算服务的 Placement API 中,用于创建虚拟机时的调度。添加 Trait API 后,注册到 Ironic 的裸机也可以通过 Trait API 注册到 Placement 资源清单中,最终支持裸机的部署调度。

本文我们实践通过 Placement 来完成裸机的调度,通过 Resource Class 来标识 ironic node 的资源类型,通过 Resource Traits 来标识 ironic node 的特征,还可以通过 resources:VCPU=0、resources:MEMORY_MB=0、resources:DISK_GB=0 来 disable scheduling。

  • 创建 Flavor
1
2
3
4
5
openstack flavor create --ram 262144 --vcpus 40 --disk 600 bms.test 
openstack flavor set --property resources:CUSTOM_BAREMETAL=1 bms.test
openstack flavor set --property resources:VCPU=0 bms.test
openstack flavor set --property resources:MEMORY_MB=0 bms.test
openstack flavor set --property resources:DISK_GB=0 bms.test
  • 验证,获取 Placement 候选人
1
2
3
4
5
6
[root@controller ~]# openstack allocation candidate list --resource VCPU=40 --resource DISK_GB=600 --resource MEMORY_MB=262144 --resource CUSTOM_BAREMETAL=1
+---+-----------------------------------------------------------+--------------------------------------+-------------------------------------------------------------------+------------------------------+
| # | allocation | resource provider | inventory used/capacity | traits |
+---+-----------------------------------------------------------+--------------------------------------+-------------------------------------------------------------------+------------------------------+
| 1 | MEMORY_MB=8192,VCPU=2,DISK_GB=100,CUSTOM_BAREMETAL_TEST=1 | e322f49a-ad50-468d-a031-29bde068c290 | VCPU=0/2,MEMORY_MB=0/8192,DISK_GB=0/100,CUSTOM_BAREMETAL_TEST=0/1 | HW_CPU_X86_VMX,CUSTOM_TRAIT1 |
+---+-----------------------------------------------------------+--------------------------------------+--------
1
2
3
4
5
6
[root@17471e0f8de8 sh1]# openstack allocation candidate list   --resource CUSTOM_BAREMETAL=1                                                             
+---+--------------------+--------------------------------------+-------------------------+---------------------------------------------+
| # | allocation | resource provider | inventory used/capacity | traits |
+---+--------------------+--------------------------------------+-------------------------+---------------------------------------------+
| 1 | CUSTOM_BAREMETAL=1 | 5e10c067-c0c6-48be-ac6e-749a70045b97 | CUSTOM_BAREMETAL=0/1 | HW_CPU_X86_VMX,COMPUTE_NET_ATTACH_INTERFACE |
+---+--------------------+--------------------------------------+-------------------------+---------------------------------------------+