openstack subnet create \
--allocation-pool ${EXT_NET_RANGE} --network public1 \
--subnet-range ${EXT_NET_CIDR} --gateway ${EXT_NET_GATEWAY} --dns-nameserver ${EXT_NET_CIDR_DNS} -- public1-subnet
# 上传部署的引导镜像
openstack image create --disk-format aki --container-format aki --public \
--file /etc/kolla/config/ironic/ironic-agent.kernel deploy-vmlinuz
openstack image create --disk-format ari --container-format ari --public \
--file /etc/kolla/config/ironic/ironic-agent.initramfs deploy-initrd
使用diskimage-builder制作ubuntu部署镜像
sudo pip install diskimage-builder
sudo apt install -y qemu-utils
disk-image-create ubuntu baremetal dhcp-all-interfaces -o my-image
将制作的用户镜像上传到 glance
glance image-create --name my-kernel --visibility public \
--disk-format aki --container-format aki < my-image.vmlinuz
glance image-create --name my-image.initrd --visibility public \
--disk-format ari --container-format ari < my-image.initrd
MY_VMLINUZ_UUID=$(glance image-list|grep my-kernel|awk -F "| " '{print $2}')
MY_INITRD_UUID=$(glance image-list|grep my-image.initrd|awk -F "| " '{print $2}')
glance image-create --name my-image --visibility public \
--disk-format qcow2 --container-format bare --property \
kernel_id=$MY_VMLINUZ_UUID --property \
ramdisk_id=$MY_INITRD_UUID < my-image.qcow2
生成ssh-key,以便免密钥登录实例
# 生成密钥对
if [ ! -f ~/.ssh/id_rsa.pub ]; then
echo Generating ssh key.
ssh-keygen -t rsa -f ~/.ssh/id_rsa
fi
if [ -r ~/.ssh/id_rsa.pub ]; then
echo Configuring nova public key and quotas.
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
fi
注册BareMetal节点,启动部署裸机的操作系统
source server_ipmi
# 物理裸机的配置,可小不可大于实际值
RAM=65536
DISK=800
VCPUS=32
HOST_CPU_ARCH=x86_64
export IRONIC_API_VERSION=1.20
DEPLOY_VMLINUZ_UUID=$(glance image-list|grep deploy-vmlinuz|awk -F "| " '{print $2}')
DEPLOY_INITRD_UUID=$(glance image-list|grep deploy-initrd|awk -F "| " '{print $2}')
# node1 创建 flavor
nova flavor-create ai-bm-node1 1 ${RAM} ${DISK} ${VCPUS}
nova flavor-key ai-bm-node1 set cpu_arch=x86_64
nova flavor-key ai-bm-node1 set resources:CUSTOM_BAREMETAL_NODE1_AI=1
nova flavor-key ai-bm-node1 set resources:VCPU=0
nova flavor-key ai-bm-node1 set resources:MEMORY_MB=0
nova flavor-key ai-bm-node1 set resources:DISK_GB=0
# 创建 node
ironic node-create -d pxe_ipmitool -n node1
NODE1_UUID=$(ironic node-list|grep node1|awk -F "| " '{print $2}')
# 设置 node 的 ipmi信息
ironic node-update $NODE1_UUID add driver_info/ipmi_username=$s1_ipmi_username \
driver_info/ipmi_password=$s1_ipmi_password driver_info/ipmi_address=$s1_ipmi_address \
driver_info/ipmi_terminal_port=623
# 设置 node 的引导镜像信息
ironic node-update $NODE1_UUID add driver_info/deploy_kernel=$DEPLOY_VMLINUZ_UUID \
driver_info/deploy_ramdisk=$DEPLOY_INITRD_UUID
# 设置 node 的基本配置信息
ironic node-update $NODE1_UUID add properties/cpus=${VCPUS} properties/memory_mb=${RAM} \
properties/local_gb=${DISK} properties/cpu_arch=${HOST_CPU_ARCH}
# 设置 node 的resource-class,方面node判断部署到哪个裸机节点
openstack --os-baremetal-api-version 1.21 baremetal node set $NODE1_UUID \
--resource-class CUSTOM_BAREMETAL_NODE1_AI
# 设置 启动网口的 MAC 地址,即 node 的 port
ironic port-create -n $NODE1_UUID -a $s1_nic_mac_address
# 设置 node状态为 provide
ironic --ironic-api-version 1.20 node-set-provision-state $NODE1_UUID manage
ironic --ironic-api-version 1.20 node-set-provision-state $NODE1_UUID provide
# 启动部署
openstack server create --image my-image --flavor ai-bm-node1 \
--key-name mykey --network public1 node1
本文涉及到的所有脚本可以到Linux公社资源站下载,详细部署可参考这套脚本
------------------------------------------分割线------------------------------------------
具体下载目录在 /2018年资料/9月/30日/OpenStack Ironic实现裸机部署/
------------------------------------------分割线------------------------------------------
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx