4.5. 创建自定义 Compute NIC 配置
此流程为 Leaf0 Leaf1 和 Leaf2 上的 Compute 节点创建 YAML 结构。
流程
进入您的自定义 NIC 目录:
$ cd ~/templates/spine-leaf-nics/-
编辑
compute0.yaml的模板。 滚动到
parameters部分中的ControlPlaneSubnetCidr和ControlPlaneDefaultRoute参数。这些参数类似于以下片断:ControlPlaneSubnetCidr: # Override this via parameter_defaults default: '24' description: The subnet CIDR of the control plane network. type: string ControlPlaneDefaultRoute: # Override this via parameter_defaults description: The default route of the control plane network. type: string修改这些参数以适合 Leaf0:
ControlPlane0SubnetCidr: # Override this via parameter_defaults default: '24' description: The subnet CIDR of the control plane network. type: string ControlPlane0DefaultRoute: # Override this via parameter_defaults description: The default route of the control plane network. type: string滚动到
parameters部分中的EC2MetadataIp参数。这个参数类似以下片断:EC2MetadataIp: # Override this via parameter_defaults description: The IP address of the EC2 metadata server. type: string修改此参数以适合 Leaf0:
Leaf0EC2MetadataIp: # Override this via parameter_defaults description: The IP address of the EC2 metadata server. type: string滚动到网络配置部分。本节类似以下片断:
resources: OsNetConfigImpl: type: OS::Heat::SoftwareConfig properties: group: script config: str_replace: template: get_file: ../../scripts/run-os-net-config.sh params: $network_config: network_config:将脚本的位置改为绝对路径:
resources: OsNetConfigImpl: type: OS::Heat::SoftwareConfig properties: group: script config: str_replace: template: get_file: /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh params: $network_config: network_config:在
network_config部分,定义 control plane / provisioning 接口。例如:network_config: - type: interface name: nic1 use_dhcp: false dns_servers: get_param: DnsServers addresses: - ip_netmask: list_join: - / - - get_param: ControlPlaneIp - get_param: ControlPlane0SubnetCidr routes: - ip_netmask: 169.254.169.254/32 next_hop: get_param: Leaf0EC2MetadataIp - ip_netmask: 192.168.10.0/24 next_hop: get_param: ControlPlane0DefaultRoute请注意,本例中使用的参数特定于 Leaf0:
ControlPlane0SubnetCidr、Leaf0EC2MetadataIp和ControlPlane0DefaultRoute。还请注意,在 provisioning 网络(192.168.10.0/24)上用于 Leaf0 的 CIDR,它用作路由。members部分中的每个 VLAN 应包含相关的 Leaf0 参数。例如,存储网络 VLAN 信息应类似于以下代码片段:- type: vlan vlan_id: get_param: Storage0NetworkVlanID addresses: - ip_netmask: get_param: Storage0IpSubnet添加一个部分来为路由定义参数。这包括 supernet 路由(本例中为
StorageSupernet)和 leaf default 路由(本例中为Storage0InterfaceDefaultRoute):- type: vlan vlan_id: get_param: Storage0NetworkVlanID addresses: - ip_netmask: get_param: Storage0IpSubnet routes: - ip_netmask: get_param: StorageSupernet next_hop: get_param: Storage0InterfaceDefaultRoute为以下控制器网络添加 VLAN 结构:
存储、InternalApi和Tenant。- 保存这个文件。
编辑
compute1.yaml并执行相同的步骤。以下是更改列表:-
将
ControlPlaneSubnetCidr更改为ControlPlane1SubnetCidr。 -
将
ControlPlaneDefaultRoute更改为ControlPlane1DefaultRoute。 -
将
EC2MetadataIp更改为Leaf1EC2MetadataIp。 -
将网络配置脚本从 ../.
/scripts/run-os-net-config.sh改为/usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh。 - 修改 control plane / provisioning 接口以使用 Leaf1 参数。
- 修改每个 VLAN,使其包含 Leaf1 路由。
完成后保存这个文件。
-
将
编辑
compute2.yaml并执行相同的步骤。以下是更改列表:-
将
ControlPlaneSubnetCidr更改为ControlPlane2SubnetCidr。 -
将
ControlPlaneDefaultRoute更改为ControlPlane2DefaultRoute。 -
将
EC2MetadataIp更改为Leaf2EC2MetadataIp。 -
将网络配置脚本从 ../.
/scripts/run-os-net-config.sh改为/usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh。 - 修改 control plane / provisioning 接口,以使用 Leaf2 参数。
- 修改每个 VLAN,使其包含 Leaf2 路由。
完成后保存这个文件。
-
将