基于OpenStack官網指導,結合實際中的應用,予以總結。
整體結構:
- Bare Metal service overview 裸金屬服務概況
- Install and configure the Bare Metal service 安裝配置裸金屬服務
-
- Install and configure for Red Hat Enterprise Linux and CentOS 紅帽7/CentOS7環境下安裝/配置
- Install and configure for Ubuntu
- Install and configure for openSUSE and SUSE Linux Enterprise
- Integration with other OpenStack services OpenStack服務內建
-
- Configure the Identity service for the Bare Metal service 裸金屬服務配置認證服務
- Configure the Compute service to use the Bare Metal service 裸金屬服務配置計算服務
- Configure the Networking service for bare metal provisioning 裸金屬privision配置網絡服務
- Configure the Image service for temporary URLs 配置鏡像服務臨時URL
- Enabling HTTPS 啟動HTTPs
- Configure the Bare Metal service for cleaning 配置裸金屬服務清理功能
- Configure tenant networks 配置租戶網絡
- Create and add images to the Image service 為鏡像服務建立鏡像
- Create flavors for use with the Bare Metal service 裸金屬服務建立flavor
- Building or downloading a deploy ramdisk image 建立/下載下傳部署ramdisk鏡像
-
- Building from source 建立源
- Set up the drivers for the Bare Metal service 建構裸金屬服務驅動
-
- Enabling drivers and hardware types 啟動drivers和hardware types
- Configuring PXE and iPXE 配置PXE/iPXE
- Configuring IPMI support 配置IPMI支援
- Configuring iSCSI-based drivers 配置基于iSCSI的驅動
- Enrollment 注冊
-
- Choosing a driver 選擇驅動
- Note on API versions API版本
- Enrollment process 注冊程式
- Logical names 邏輯命名
- Defaults for hardware interfaces 預設硬體接口
- Hardware Inspection 硬體檢查
- Tenant Networks and Port Groups 租戶網絡和端口組
- Using Bare Metal service as a standalone service 裸金屬服務作為獨立服務使用
-
- Other references 其它參考
- Enabling the configuration drive (configdrive) 啟用configdrive
-
- When used with Compute service 結合計算服務的使用
- When used standalone 獨立服務下的使用
- Configuration drive storage in an object store 在對象存儲中配置configdrive
- Accessing the configuration drive data 通路configdrive資料
- Cloud-init integration Cloud-init內建
- Advanced features 進階特性
-
- Local boot with partition images partition鏡像本地引導
- Specifying the disk for deployment (root device hints) 指定部署的磁盤(根裝置所在磁盤)
- Appending kernel parameters to boot instances 引導執行個體時添加核心參數
- Boot mode support 引導模式支援
- Choosing the disk label 選擇磁盤标簽
- Trusted boot with partition image 可信任的partation鏡像
- Notifications 通知
- Configuring node web console 配置節點控制台
- Troubleshooting 疑難問題解答
-
- Maintenance mode 維護模式
- Next steps 下一步
一, 裸金屬服務概況
裸金屬服務( Bare Metal service)是一系列用于提供支援管理和部署實體伺服器的元件集合。
裸金屬服務的項目名稱為ironic,裸金屬服務根據具體的配置,與其它openstack元件互相配合使用,包括: 1)通過IPMI實作和計量資料收集服務ceilometer元件的對接 2)keystone認證服務 3)用于檢索鏡像和鏡像meta-data的glance服務 4)用于DHCP和網絡配置的neutron服務 5)與 Bare Metal service協作進行的nova計算服務元件,Bare Metal service提供硬體管理服務,nova提供執行個體管理的使用者API接口。 nova計算服務同時提供排程能力,用于比對flavor、image、租戶配額,ip指定等其它 Bare Metal service服務本身沒有的服務。 6)swift對象存儲服務
裸金屬服務包括以下元件: 1, ironic-api 一個 RESTful API,用來處理使用者的請求,接受請求後,通過RPC把請求發送給 ironic-conductor。 2, ironic-conductor 添加/修改/删除節點;通過IPMI協定或其它使用者指定協定,來對nodes裸金屬節點進行開關機; 提供/部署/清除裸金屬節點。 3, ironic-python-agent 在ramdisk臨時記憶體虛拟盤系統運作的一個python代理服務,用于提供外部ironic-conductor服務和ironic-inspector服務的遠端通路,以及帶内硬體控制,和硬體自檢功能。 此外,和其它openstack服務類似, Bare Metal service服務也有一定的外部服務依賴: 1)database資料庫:來存儲硬體資訊和狀态,可以設定背景資料庫類型和位置。一個簡單方法是和計算節點使用同樣的背景資料庫; 2)消息隊列.例如 RabbitMQ.可以使用與計算服務相同的實作,但這沒有具體要求,能通信就行。
另外,利用以下相關的項目可以獲得額外的功能。 1, python-ironicclient 通過ironicclient python API可以通路ironic,有兩種CLI可以通路: (1)Ironic用戶端指令行(CLI) 調用格式: ironic [options] <command> [command-options] ironic help ironic help <command>
Ironic Client Command-Line Interface (CLI)與OpenStack的Bare Metal Service (即Ironic)互相作用。 例如: 擷取可用的ironic driver清單、節點清單,建立節點等操作。 $ ironic driver-list $ ironic node-list $ ironic node-create -d fake_ipmitool -i ipmi_address=1.2.3.4
(2)OpenStack用戶端指令行(CLI) 調用格式: openstack [options] baremetal <command> [command-options] openstack help baremetal <command> 例如:擷取可用的ironic driver清單、節點清單,建立節點等操作。 $ openstack baremetal driver list $ openstack baremetal node create --driver agent_ipmitool --driver-info ipmi_address=1.2.3.4 $ openstack baremetal node list
要使用以上這兩個CLI,執行指令前,都必須要提供openstack的使用者名密碼項目、認證接口等,需要配置--os-username, --os-password, --os-project-id (or --os-project-name), --os-auth-url,可以把這些參數寫入環境變量中: $ export OS_USERNAME =user $ export OS_PASSWORD =password $ export OS_PROJECT_NAME =project # or OS_PROJECT_ID,最好寫name $ export OS_PROJECT_DOMAIN_ID =default
$ export OS_USER_DOMAIN_ID =default
$ export OS_IDENTITY_API_VERSION = 3
$ export OS_AUTH_URL =http://auth.example.com:5000/identity
2, ironic-inspector 一個通過PXE啟動未注冊硬體到ironic- pythonagent ramdisk上執行帶内硬體内省的服務。
3, diskimage-builder 用于建立ramdisk和實體機鏡像的一個相關項目
4, bifrost 一組Ansible腳本,它可以在standalone模式下,自動地将一個基礎鏡像部署到一組已知的硬體上。
二, 安裝配置裸金屬服務
此處以 Red Hat Enterprise Linux 7/CentOS的安裝配置舉例
1,安裝配置前提 裸金屬服務是提供管理和供應實體伺服器的元件集合。你可以配置這些元件運作在分離的節點或相同的節點上。這個指導中,元件運作在同一個節點上,一般運作在計算服務的計算節點上。 此處,假設認證、鏡像、計算和網絡服務都已經配置好了。
1.1 為裸金屬配置資料庫 裸金屬服務在資料庫中存儲資訊。此指導中使用其它openstack服務都使用的MySQL資料庫 在MySQL資料庫中,建立ironic資料庫,并且使ironic使用者可以通路,修改IRONIC_DBPASSWORD為自定義的密碼: # mysql -u root -p mysql> CREATE DATABASE ironic CHARACTER SET utf8; mysql> GRANT ALL PRIVILEGES ON ironic.* TO 'ironic'@'localhost' IDENTIFIED BY 'IRONIC_DBPASSWORD'; mysql> GRANT ALL PRIVILEGES ON ironic.* TO 'ironic'@'%' IDENTIFIED BY 'IRONIC_DBPASSWORD'; 2, 元件安裝配置 使用yum安裝相關應用包: # yum install openstack-ironic-api openstack-ironic-conductor python-ironicclient
啟動服務: # systemctl enable openstack-ironic-api openstack-ironic-conductor
# systemctl start openstack-ironic-api openstack-ironic-conductor
裸金屬服務的本地配置檔案是:/etc/ironic/ironic.conf,可以參考Sample Configuration File ,根據需要來進行配置 ironic-api和ironic-conductor可以在同一主機上,也可以在不同主機。使用者也可以添加新的ironic-conductor主機去處理不斷增長的裸金屬節點[Pike版本],但是新增的ironic-conductor服務應該和原來的ironic-conductor版本一緻。
2.1 配置ironic-api服務 (1)裸金屬服務在資料庫中存儲資訊。此指導中使用其它openstack服務都使用的MySQL資料庫 通過配置檔案中的connection選項配置本地資料庫。如下,把IRONIC_DBPASSWORD替換為ironic使用者的自定義密碼,DB_IP替換為本地資料庫服務的位址。 [database]
# The SQLAlchemy connection string used to connect to the # database (string value) connection = mysql+pymysql://ironic:[email protected]_IP/ironic?charset=utf8 (2)配置ironic-api服務使用RabbitMQ消息代理,使用如下配置,替換RPC_*為RabbitMQ的位址、密碼、主機名、端口等。
[DEFAULT]
# A URL representing the messaging driver to use and its full # configuration. (string value) transport_url = rabbit://RPC_USER:[email protected]_HOST:RPC_PORT/ (3)配置ironic-api服務使用認證資訊的認證服務,替換PUBLIC_IDENTITY_IP為公網的認證服務IP,替換PRIVATE_IDENTITY_IP為私網的認證服務IP,替換IRONIC_PASSWORD為ironic使用者在認證服務的自定義密碼。
[DEFAULT]
# Authentication strategy used by ironic-api: one of # "keystone" or "noauth". "noauth" should not be used in a # production environment because all authentication will be # disabled. (string value) auth_strategy = keystone
[keystone_authtoken]
# Authentication type to load (string value) auth_type = password
# Complete public Identity API endpoint (string value) auth_uri = http://PUBLIC_IDENTITY_IP:5000
# Complete admin Identity API endpoint. (string value) auth_url = http://PRIVATE_IDENTITY_IP:35357
# Service username. (string value) username = ironic
# Service account password. (string value) password = IRONIC_PASSWORD
# Service tenant name. (string value) project_name = service
# Domain name containing project (string value) project_domain_name = Default
# User's domain name (string value) user_domain_name = Default (4)建立裸金屬服務資料庫表
$ ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema (5)重新開機ironic-api服務
Fedora/RHEL7/CentOS7/SUSE: sudo systemctl restart openstack-ironic-api
2.2 配置ironic-conductor服務 (1)替換HOST_IP為conductor的IP。 如果conductor有多個IP,my_ip應該設定為和裸金屬節點在同一網段的IP。(若conductor有多個網段IP,此處設定的IP需要能直接和裸金屬節點通信) [DEFAULT]
# IP address of this host. If unset, will determine the IP # programmatically. If unable to do so, will use "127.0.0.1". # (string value) my_ip = HOST_IP (2)配置ironic-api服務的URL,替換IRONIC_API_IP為ironic-api服務的IP [conductor]
# URL of Ironic API service. If not set ironic can get the # current value from the keystone service catalog. (string # value) api_url = http://IRONIC_API_IP:6385 (3)配置本地資料庫,Ironic-conductor應該和ironic-api使用相同配置。替換IRONIC_DBPASSWORD為ironic使用者的自定義密碼,DB_IP替換為本地資料庫服務的位址。 [database]
# The SQLAlchemy connection string to use to connect to the # database. (string value) connection = mysql+pymysql://ironic:[email protected]_IP/ironic?charset=utf8 (4)配置ironic-api服務使用RabbitMQ消息代理,使用如下配置,Ironic-conductor應該和ironic-api使用相同配置,替換RPC_*為RabbitMQ的位址、密碼、主機名、端口等。 [DEFAULT]
# A URL representing the messaging driver to use and its full # configuration. (string value) transport_url = rabbit://RPC_USER:[email protected]_HOST:RPC_PORT/ (5)配置ironic-conductor服務使其可以和鏡像服務通信,替換GLANCE_IP為鏡像服務的hostname或IP位址。 注意: swift背景的鏡像服務必須安裝和配置agent_*驅動,Ceph對象網關也支援作為鏡像的背景服務。 [glance]
# Default glance hostname or IP address. (string value) glance_host = GLANCE_IP (6)替換NEUTRON_IP,設定網絡服務連接配接的URL,作為網絡服務的endpoint。 (Endpoint:一個可以通過網絡來通路和定位某個Openstack service的位址,通常是一個URL。比如,當Nova需要通路Glance服務去擷取image 時,Nova通過通路Keystone拿到Glance的endpoint,然後通過通路該endpoint去擷取Glance服務。) [neutron]
# URL for connecting to neutron. (string value) url = http://NEUTRON_IP:9696
(7)配置通路其他OpenStack服務的認證資訊。 為了和其他OpenStack服務連通,裸金屬服務需要在向其它服務發送請求時,先使用服務使用者通過openstack認證服務的驗證。這些使用者的認證需在配置檔案中相關服務的位置進行配置。
-
- 用于通路OpenStack網絡服務[neutron]
-
- 用于通路OpenStack鏡像服務[glance]
-
- 用于通路OpenStack對象存儲服務[swift]
-
- 用于通路OpenStack自檢服務[inspector]
-
- 在OpenStack認證服務目錄中注冊裸金屬服務的一個特殊持有憑證,用于發現ironic API的URL endpoint .[service_catalog]
(8)通過設定啟用的驅動程式配置選項,可以在ironic服務的配置檔案中啟用驅動程式。 [DEFAULT] enabled_drivers = pxe_ipmitool,pxe_ilo,pxe_drac (9)重新開機ironic-conductor服務 Fedora/RHEL7/CentOS7/SUSE: sudo systemctl restart openstack-ironic-conductor
三, OpenStack服務內建
(一)配置裸金屬認證服務
1,建立裸金屬服務使用者(例如ironic)。服務使用這個來對身份進行驗證。使用service租戶并給此使用者提供admin角色
$ openstack user create --password IRONIC_PASSWORD \
--email [email protected] ironic $ openstack role add --project service --user ironic admin 2,必須使用Identity service注冊裸金屬服務,以便其它OpenStack服務能夠通路它 $ openstack service create --name ironic --description \ "Ironic baremetal provisioning service" baremetal 3,使用注冊(第2步)服務時使用的認證服務傳回的id屬性,來建立endpoint端點,并把以下IRONIC_NODE替換為裸金屬服務API節點所在的IP $ openstack endpoint create --region RegionOne \
baremetal admin http:// $IRONIC_NODE:6385
$ openstack endpoint create --region RegionOne \
baremetal public http:// $IRONIC_NODE:6385
$ openstack endpoint create --region RegionOne \
baremetal internal http:// $IRONIC_NODE:6385
4,通過使用OpenStack身份認證服務建立角色,可以指派你的使用者擁有與裸金屬服務相關的有限特權,在預設情況下,裸金屬服務除了預設的管理角色外,還期望出現“baremetal_admin”和“baremetal_observer”角色。如果您選擇不建立這些角色,也不會産生負面影響。可以使用以下指令建立它們 $ openstack role create baremetal_admin
$ openstack role create baremetal_observer
如果您選擇自定義裸金屬服務使用的角色名稱,那麼通過更改/etc/ironic/policy.json中的“is_member”, “is_observer”, 和“is_admin”政策來實作。 關于在OpenStack部署中管理使用者和角色的更完整的文檔超出了本文的範圍,但是可以在這裡找到 here .
5,可以通過建立一個單獨的baremetal項目來進一步限制對裸金屬服務的通路,進而使裸金屬資源(節點、端口等)隻能被該項目的成員通路。 $ openstack project create baremetal
在這一點上,您可以對裸金屬服務API授予隻讀通路權,而不允許通過發出以下指令來授予任何其他通路權限 $ openstack user create \
--domain default --project-domain default --project baremetal \
--password PASSWORD USERNAME
$ openstack role add \
--user-domain default --project-domain default --project baremetal \
--user USERNAME baremetal_observer
6,對于openstack指令行用戶端和身份服務,還有其他文檔可用。policy.json.sample檔案列舉了服務的預設政策,為您提供了使用裸金屬服務的便利。
(二)配置裸金屬計算服務
1, 計算服務需要配置為使用裸金屬服務的驅動程式。計算服務的配置檔案通常位于 /etc/nova/nova.conf。 注意: 和Newton版本一樣,也可以有多個nova-compute服務運作ironic作為nova底層驅動,以提供備援。裸金屬節點通過散列環映射到服務。如果服務挂掉,可用的裸金屬節點将重新映射到不同的服務。一旦節點服務又激活,節點就會被映射到同樣的nova-compute直到它down掉。節點無法通過計算API進行管理,除非服務狀态傳回到active狀态。 【Mitaka版本隻支援一個compute,生産環境中運作有一定風險】 [default]
# Defines which driver to use for controlling virtualization. # Enable the ironic virt driver for this compute instance. compute_driver = ironic.IronicDriver
# Firewall driver to use with nova-network service. # Ironic supports only neutron, so set this to noop. firewall_driver = nova.virt.firewall.NoopFirewallDriver
# Amount of memory in MB to reserve for the host so that it is always # available to host processes. # It is impossible to reserve any memory on bare metal nodes, so set # this to zero. reserved_host_memory_mb = 0
[filter_scheduler]
# Enables querying of individual hosts for instance information. # Not possible for bare metal nodes, so set it to False. track_instance_changes = False
[scheduler]
# This value controls how often (in seconds) the scheduler should # attempt to discover new hosts that have been added to cells. # If negative (the default), no automatic discovery will occur. # As each bare metal node is represented by a separate host, it has # to be discovered before the Compute service can deploy on it. # The value here has to be carefully chosen based on a compromise # between the enrollment speed and the load on the Compute scheduler. # The recommended value of 2 minutes matches how often the Compute # service polls the Bare Metal service for node information. discover_hosts_in_cells_interval = 120 2,如果還沒有切換到基于資源類的排程 Scheduling based on resource classes ,那麼應該設定以下選項。在切換到資源類之後,必須将它們從配置檔案中删除。 [scheduler]
# Use the ironic scheduler host manager. This host manager will consume # all CPUs, disk space, and RAM from a host as bare metal hosts, can not # be subdivided into multiple instances. Scheduling based on resource # classes does not use CPU/disk/RAM, so the default host manager can be # used in such cases. host_manager = ironic_host_manager
[filter_scheduler]
# Size of subset of best hosts selected by scheduler. # New instances will be scheduled on a host chosen randomly from a # subset of the 999 hosts. The big value is used to avoid race # conditions, when several instances are scheduled on the same bare # metal nodes. This is not a problem when resource classes are used. host_subset_size = 999
# This flag enables a different set of scheduler filters, which is more # suitable for bare metals. CPU, disk and memory filters are replaced # with their exact counterparts, to make sure only nodes strictly # matching the flavor are picked. These filters do not work with # scheduling based on resource classes only. use_baremetal_filters = True 3,仔細考慮以下選項 【此參數是連續建構服務禁用的門檻值,預設是禁用的,如果設定為非0,nova-compute服務将會被禁用,用于防止在連續建構失敗後,排程器不斷向失敗的服務發送建構請求,總之,謹慎使用】
[compute]
# This option will cause nova-compute to set itself to a disabled state # if a certain number of consecutive build failures occur. This will # prevent the scheduler from continuing to send builds to a compute # service that is consistently failing. In the case of bare metal # provisioning, however, a compute service is rarely the cause of build # failures. Furthermore, bare metal nodes, managed by a disabled # compute service, will be remapped to a different one. That may cause # the second compute service to also be disabled, and so on, until no # compute services are active. # If this is not the desired behavior, consider increasing this value or # setting it to 0 to disable this behavior completely. #consecutive_build_service_disable_threshold = 10 4,在配置選項的ironic部分中更改以下内容。替換:
-
在認證服務中ironic使用者的密碼IRONIC_PASSWORD
-
ironic-api所在節點的主機名或IP位址IRONIC_NODE
-
認證伺服器的IPIDENTITY_IP
[ironic]
# Ironic authentication type auth_type = password
# Keystone API endpoint auth_url = http://IDENTITY_IP:35357/v3
# Ironic keystone project name project_name = service
# Ironic keystone admin name username = ironic
# Ironic keystone admin password password = IRONIC_PASSWORD
# Ironic keystone project domain # or set project_domain_id project_domain_name = Default
# Ironic keystone user domain # or set user_domain_id user_domain_name = Default 5,在計算服務的控制器節點上,重新開機nova-scheduler服務 Fedora/RHEL7/CentOS7/SUSE: sudo systemctl restart openstack-nova-scheduler 6,在計算服務的計算節點,重新開機nova-compute服務 Fedora/RHEL7/CentOS7/SUSE: sudo systemctl restart openstack-nova-compute
(三)配置裸金屬網絡服務
需要配置網絡,這樣裸金屬服務就可以與網絡服務通信,用于DHCP、PXE啟動和其它需求。本節将介紹為裸金屬供應配置單個扁平網絡的網絡。還需要為裸金屬服務提供每個節點的mac位址;裸金屬服務依次将此資訊傳遞給DHCP和PXE啟動配置的網絡服務。 在 Enrollment 章節 部分有一個例子。 1,編輯修改
/etc/neutron/plugins/ml2/ml2_conf.ini
[ml2] type_drivers = flat tenant_network_types = flat mechanism_drivers = openvswitch
[ml2_type_flat] f lat_networks = physnet1
[securitygroup] firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver enable_security_group = True
[ovs] bridge_mappings = physnet1:br-eth2 # Replace eth2 with the interface on the neutron node which you # are using to connect to the bare metal server
2,如果neutron-openvswitch-agent服務把ovs_neutron_plugin.ini作配置檔案運作,編輯ovs_neutron_plugin.ini,像上一步一樣,通過在[ovs]部分添加橋接映射配置,然後重新開機neutron-openvswitch-agent服務。
3,在openvswitch中添加內建網橋br-int $ ovs-vsctl add-br br-int
4,建立br-eth2網絡橋,使用eth2來處理OpenStack服務(和裸金屬服務)和裸金屬實體伺服器節點之間的通信。将eth2替換為連接配接到裸金屬服務的網絡節點上的接口: $ ovs-vsctl add-br br-eth2
$ ovs-vsctl add-port br-eth2 eth2
5,重新開機Open vSwitch代理
# service neutron-plugin-openvswitch-agent restart
6,在重新啟動網絡服務Open vSwitch代理時,将自動建立橋br-int和br-eth2之間的veth對。 您的打開的Open vSwitch橋應該如下: $ ovs-vsctl show
Bridge br-int fail_mode: secure Port "int-br-eth2" Interface "int-br-eth2" type: patch options: {peer="phy-br-eth2"} Port br-int Interface br-int type: internal Bridge "br-eth2" Port "phy-br-eth2" Interface "phy-br-eth2" type: patch options: {peer="int-br-eth2"} Port "eth2" Interface "eth2" Port "br-eth2" Interface "br-eth2" type: internal ovs_version: "2.3.0" 7,建立用于啟動執行個體的flat網絡 $ neutron net-create --tenant-id $TENANT_ID sharednet1 --shared \ --provider:network_type flat --provider:physical_network physnet1 8,在新建立的網絡上建立子網 $ neutron subnet-create sharednet1 $NETWORK_CIDR --name $SUBNET_NAME \
--ip-version = 4 --gateway = $GATEWAY_IP --allocation-pool \
start = $START_IP,end = $END_IP --enable-dhcp
(四)配置裸金屬鏡像臨時URLs
一些Baremetal服務的驅動程式(特别是,任何agent_*的驅動程式,任何使用直接部署接口的新型驅動程式,以及一些虛拟媒體驅動程式)都要求目标使用者鏡像可以通過不涉及身份驗證的clean HTTP(S) URL獲得(沒有使用者名/密碼,沒有token)。 當使用在OpenStack中內建的Baremetal服務時,可以通過鏡像服務和對象存儲服務的特定配置實作,如下所述。 1,将鏡像服務配置為将對象存儲,作為存儲鏡像的後端。有關更多細節,請參考鏡像服務配置指南。 注意: 當在對象存儲服務中使用Ceph+RadosGW時,存儲在鏡像服務中的鏡像,也必須在對象存儲服務上可用 。
2,在對象存儲服務中,為鏡像存儲開啟TempURLs用于鏡像服務 a.檢查 TempURLs 是否啟用 # executed under credentials of the user used by Image service # to access Object Storage service
$ openstack object store account show
+------------+---------------------------------------+
| Field | Value |
+------------+---------------------------------------+
| Account | AUTH_bc39f1d9dcf9486899088007789ae643 | | Bytes | 536661727 | | Containers | 1 | | Objects | 19 | | properties | Temp-Url-Key = 'secret' |
+------------+---------------------------------------+
b.如果 Temp-Url-Key 啟用,觀察它的值 c.如果 Temp-Url-Key 沒有啟用,需要手動配置(下面例子中使用了secret) $ openstack object store account set --property Temp-Url-Key =secret
3,配置ironic-conductor服務。配置檔案通常位于/etc/ironic/ironic.conf。一些必需的值可以在openstack object store account show指令的響應中獲得;其它必須比對配置檔案中配置的鏡像和對象存儲服務。 以下是當對象存儲服務由swift提供時的最小配置的例子,下面是一個最簡單的配置例,用來指定對的(可以在etc/ironic/ironic.conf.sample配置檔案中檢視完整可用的配置及其較長的描述): [glance]
temp_url_endpoint_type = swift swift_endpoint_url = http://openstack/swift swift_account = AUTH_bc39f1d9dcf9486899088007789ae643 swift_container = glance swift_temp_url_key = secret 4,重新開機ironic-conductor服務
(五)啟用HTTPS
1,在Swift中啟用HTTPs 使用虛拟媒介的驅動程式,使用swift來存儲boot引導鏡像和節點配置資訊(包含Ironic conductor預提供裸金屬硬體的敏感資訊)。預設情況下,HTTPS不能在swift中啟用。HTTPS被要求加密swift、Ironic conductor、swift、裸金屬之間的所有通信(通過虛拟媒體)。它可以通過以下一種方式啟用:
- 使用SSL終端代理。
- 在swift中使用本地SSL支援(僅用于swift的測試目的)
2,在鏡像服務中啟用HTTPS 在節點供應期間,Ironic驅動經常會使用鏡像服務。預設情況下,鏡像服務不使用HTTPS,但是當需要安全通信時,它是必需的。可以通過更改/etc/glance/glance-api.conf來啟用它。 (1) Configuring SSL support
配置SSL支援
-
cert_file=PATH
-
Path to the certificate file the server should use when binding to an SSL-wrapped socket.
Optional. Default: not enabled.
-
key_file=PATH
-
Path to the private key file the server should use when binding to an SSL-wrapped socket.
Optional. Default: not enabled.
-
Path to the CA certificate file the server should use to validate client certificates provided during an SSL handshake. This is ignored ifca_file=PATH
cert_file
and ‘’key_file`` are not set.
Optional. Default: not enabled.
(2)重新開機glance-api服務: Fedora / RHEL7 / CentOS7 / SUSE : sudo systemctl restart openstack - glance - api 3,在鏡像服務和對象存儲之間開啟HTTPs連接配接
本節描述了在使用對象存儲作為後端時,在鏡像服務和對象存儲之間啟用安全HTTPS通信所需的步驟。 為了在鏡像服務和對象存儲之間啟用安全的HTTPS通信,請遵循以下步驟:
- Enabling HTTPS in Swift
- Configure Swift Storage Backend
- Enabling HTTPS in Image service
4,在鏡像服務和裸金屬之間開啟HTTPs連接配接 本節描述在鏡像服務和裸金屬服務之間啟用安全HTTPS通信所需的步驟。 為了在裸金屬服務和鏡像服務之間啟用安全的HTTPS通信,需要遵循以下步驟:
(1)編輯 /etc/ironic/ironic.conf [ glance ] ... glance_cafile =/ path / to / certfile glance_protocol = https glance_api_insecure = False 注意: “glance cafile”是驗證CA憑證的可選路徑,用來驗證由鏡像服務提供的SSL證書。
(2)重新開機 ironic-conductor服務 Fedora / RHEL7 / CentOS7 / SUSE :
sudo systemctl restart openstack - ironic - conductor
(六)配置裸金屬清理操作
如果你将裸金屬服務配置為自動清理(預設情況下是啟用的),将需要設定清理網絡的配置選項。 1,注意在配置網絡服務時所建立的網絡UUID(id字段),用于裸金屬供應,或者也可以再建立一個用于清理的網絡。 $ neutron net-list 2, 在裸金屬服務配置檔案 /etc/ironic/ironic.conf中,通過 cleaning_network選項配置清理網絡的UUID,把 NETWORK_UUID替換為上一步指定的網絡uuid [neutron] cleaning_network = NETWORK_UUID 3,重新開機 ironic-conductor Fedora/RHEL7/CentOS7/SUSE: sudo systemctl restart openstack-ironic-conductor
ironic節點清理功能擴充: https://docs.openstack.org/ironic/pike/admin/cleaning.html#automated-cleaning
(七)配置租戶網絡
下面是 在多租戶環境中 設定裸金屬服務,以 實作節點供應 的示例流程(使用上面所述的neutron網絡接口)
1, 通過在配置檔案的[default]分段下,添加enabled_network_interfaces配置選項,可實作ironic-conductor服務的網絡接口使能。 [ DEFAULT ] ... enabled_network_interfaces = noop , flat , neutron 請記住,在理想情況下,所有的ironic-conductors都應該具有相同的使能網絡接口清單,但在ironic-conductor更新時可能不是這樣。如果ironic-conductors其中的一個挂掉了,那麼一些被接管的節點能會被被映射到一個不支援節點網絡接口的ironic-conductor,這就可能會導緻一些問題。任何涉及調用該節點的驅動程式的操作都将失敗,除非該網絡接口被安裝并啟用了這個ironic-conductor。
2,建議在配置檔案的[default]分段中,通過預設的default_network_interface配置選項,設定預設的網絡接口。 [ DEFAULT ] ... default_network_interface = neutron 這個預設值将用于所有沒有在建立請求中顯式指定的網絡接口的節點。
如果這個配置選項沒有設定,預設的網絡接口是通過檢視[dhcp]dhcp_provider中配置項的值, 如果是配置的neutron,那麼flat網絡變為預設值;否則noop為預設值。
3,在網絡服務中定義一個provider網絡,我們将其稱為“provisioning”網絡,并将其添加到ironic-conductor配置檔案的[neutron]分段中。使用neutron網絡接口,需要使用網絡服務中的網絡有效辨別符(UUID或名稱)設定provisioning_network和cleaning_network配置選項。如果沒有正确設定這些選項,cleaning或provisioning将無法啟動。 [neutron]
...
cleaning_network=$CLEAN_UUID_OR_NAME
provisioning_network=$PROVISION_UUID_OR_NAME
關于更詳細的節點清理操作,可以參考: Configure the Bare Metal service for cleaning
警告 請確定裸金屬服務具有對provisioning和cleaning網絡的專有通路權。如果非管理者使用者使用這些網絡生成執行個體,并通路裸金屬服務控制平台是有安全風險的。出于這個原因,provisioning和cleaning網絡應該在admin租戶中配置為非共享網絡。
注意 在provisioning網絡上生成一個裸金屬執行個體是不可能的,部署将會失敗。應該将節點部署到與provisioning網絡不同的網絡上。當你從計算服務中啟動一個裸金屬執行個體時,應該為執行個體的網絡服務中選擇一個不同的網絡。
“provisioning”和“cleaning”網絡可能是相同的網絡或不同的網絡。為了確定裸金屬服務和部署ramdisk之間的通信,重要的是確定安全組在這些網絡中被禁用,或者預設允許安全組如下:
- DHCP
- TFTP
- 用于裸金屬服務的出端口egress port(預設6385)
- 用于ironic-python-agent入端口ingress port (預設9999)
- 如果使用iSCSI部署方法(
和pxe_*
驅動), 入端口ingress port使用iSCSI (預設3260)iscsi_*
- 如果使用直接部署方法 (
驅動), 出端口egress port使用對象存儲服務(通常是80或443)agent_*
- 如果使用iPXE, 出端口egress port使用運作在ironic-conductor節點上的HTTP服務(通常是80).
4,這一步是可選的,并且隻有當你想在節點provisioning和/或cleaning時使用安全組時才适用。 如果沒有指定,則使用預設安全組。 a, 在網絡服務中定義安全組,用于provisioning和/或cleaning網絡。 b, 在ironic-conductor的配置檔案的[neutron]分段中,添加這些安全組的UUIDs清單,如下所示: [neutron]
...
cleaning_network=$CLEAN_UUID_OR_NAME
cleaning_network_security_groups=[$LIST_OF_CLEAN_SECURITY_GROUPS]
provisioning_network=$PROVISION_UUID_OR_NAME
provisioning_network_security_groups=[$LIST_OF_PROVISION_SECURITY_GROUPS]
多個安全組可以應用于給定的網絡,是以,它們被指定為一個清單。同一個的安全組可以同時用于provisioning和cleaning網絡 .
警告 如果安全組按照上面的描述配置,則不要為網絡或端口的相應網絡服務設定“port_security_enabled”标志為false。這将導緻部署失敗。例如:如果使用provisioning_network_security_groups配置選項,則確定“port_security_enabled”啟用标志被設定為True。預設情況下,該标志将被設定為True;請確定不要通過手動将其設定為False來覆寫它。
5,安裝和配置一個相容的ML2機制驅動程式,來提供裸金屬provisioning交換機的支援。 更多ML2詳情檢視: ML2 plugin configuration manual
6,在以上修改之後,重新開機ironic-conductor和ironic-api服務 Fedora/RHEL7/CentOS7: sudo systemctl restart openstack - ironic - api sudo systemctl restart openstack - ironic - conductor
7,確定ironic-conductor通過provisioning網絡可以從TFTP伺服器上下載下傳一個檔案,從該網絡中的某個非控制平台伺服器上下載下傳。 tftp $TFTP_IP -c get $FILENAME
FILENAME指的是位于TFTP server上的檔案。
(八)向鏡像服務中添加裸金屬鏡像
裸金屬預配置需要兩組鏡像:部署鏡像和使用者鏡像。部署鏡像被裸金屬服務使用,為通過裸金屬服務實作OS的部署做準備。而使用者鏡像則是存放在裸金屬服務上,供最終使用者使用。下面是建立所需鏡像并将其添加到鏡像服務的步驟:
1,建立使用者鏡像
disk-image-builder 可用于建立使用者将要部署和運作的實際作業系統所需使用者鏡像。
(1)安裝diskimage-builder包(如果不想全局安裝,可以使用virtualenv) # pip install diskimage-builder
(2)建立使用者将要運作使用的鏡像(以ubuntu為例)
- Partition images
$ disk-image-create ubuntu baremetal dhcp-all-interfaces grub2 -o my-image
-
Whole disk images
$ disk-image-create ubuntu vm dhcp-all-interfaces -o my-image
分區鏡像建立my-image.qcow2, my-image.vmlinuz和my-image.initrd三個檔案, 隻有當部署my-image.qcow2需要本地引導時,才需要在partition鏡像的建立指令中指定grub2參數。 否則,my-image.vmlinuz和my-image.initrd将在部署完my-image.qcow2裸金屬鏡像之後,用于裸金屬的PXE啟動。
如果要使用Fedora鏡像,把ubuntu替換為Fedora即可。
2,把使用者鏡像添加到鏡像服務中 将下面步驟中建立的所有鏡像加載到鏡像服務中,在鏡像服務中為每一個生成的鏡像記錄image uuid。 (1)把kernel和ramdisk鏡像添加到鏡像服務中
$ glance image-create --name my-kernel --visibility public \ --disk-format aki --container-format aki < my-image.vmlinuz 記錄上一步驟中image uuid 為MY_VMLINUZ_UUID $ glance image-create --name my-image.initrd --visibility public \ --disk-format ari --container-format ari < my-image.initrd 記錄上一步驟中image uuid 為 MY_INITRD_UUID (2) 把my-image添加到鏡像服務中,這将是使用者将要運作的作業系統。同時還需要将上面建立的鏡像與這個OS鏡像關聯起來。這兩個操作可以通過執行以下指令來完成 $ 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
注意: 要部署whole磁盤鏡像,kernel_id和ramdisk_id不應該與使用者鏡像相關聯,例如: $ glance image-create --name my-whole-disk-image --visibility public \
--disk-format qcow2 \
--container-format bare < my-whole-disk-image.qcow2
3,建立和下載下傳部署鏡像 部署鏡像用于在部署實際作業系統之前對伺服器的初始化準備工作(例如:建立磁盤分區)。有幾種方法可以建構或下載下傳部署鏡像。具體可檢視: Building or downloading a deploy ramdisk image 如果要自定義部署鏡像,可檢視:Image Builders
4,把部署鏡像添加到鏡像服務中 把coreos_production_pxe.vmlinuz and coreos_production_pxe_image-oem.cpio.gz添加到鏡像服務中。 $ glance image-create --name deploy-vmlinuz --visibility public \
--disk-format aki --container-format aki < coreos_production_pxe.vmlinuz
$ glance image-create --name deploy-initrd --visibility public \ --disk-format ari --container-format ari < coreos_production_pxe_image-oem.cpio.gz
(九)為裸金屬服務建立flavor
基于屬性的排程Scheduling 需要在計算服務中建立一個特殊的裸金屬規格,通過硬體規格将flavor映射到裸金屬節點上。 1,指定硬體變量 $ RAM_MB = 1024 $ CPU = 2 $ DISK_GB = 100 $ ARCH ={i686 |x86_64 } 2,使用指令行建立裸金屬規格 $ nova flavor-create my-baremetal-flavor auto $RAM_MB $DISK_GB $CPU 可以把auto替換為自定義flavor uuid。 3,設定flavor屬性額外自定義的指定資訊 $ nova flavor-key my-baremetal-flavor set cpu_arch = $ARCH
四, 建立/下載下傳部署ramdisk鏡像
ironic依賴于帶有ironic-python-agent運作的鏡像,用于控制和部署裸金屬節點。 您可以使用 CoreOS tools ,在以下位址下載下傳與此建構的部署ramdisk的預建構版本
從源代碼建構 有兩種已知的方法來建立使用IPA服務的部署鏡像。 1,CoreOS tools 略 2,disk-image-builder (1)根據 diskimage-builder installation documentation文檔,安裝diskimage-builder (2)建立鏡像 disk - image - create ironic - agent fedora - o ironic - deploy 以上指令會在目前目錄建立名字為ironic-deploy.vmlinuz和ironic-deploy.initramfs的部署鏡像ramdisk和kernel。
3,通過虛拟媒體建立一個可以引導的iso鏡像 disk - image - create ironic - agent fedora iso - o ironic - deploy 以上指令會在目前目錄建立名字為ironic-deploy.iso的部署ISO。
參考:
https://docs.openstack.org/ironic/pike/install/index.html