Red Hat Training
A Red Hat training course is available for Red Hat OpenStack Platform
第3章 仮想ネットワークの SR-IOV サポートの設定
本章では、director を使用した Red Hat OpenStack Platform 11 環境への Single Root Input/Output Virtualization (SR-IOV) の設定について説明します。
以下の手順では、network-environment.yaml ファイルを更新して、カーネルの引数、SR-IOV ドライバー、PCI パススルーなどのパラメーターを追加します。また、compute.yaml ファイルも更新して SR-IOV インターフェースのパラメーターを追加してから、overcloud_deploy.sh スクリプトを実行して、その SR-IOV パラメーターを使用してオーバークラウドをデプロイする必要があります。

3.1. VLAN トンネリングを使用する単一 NIC の SR-IOV コンポーザブルロールの設定
本項では、OpenStack 環境向けに VLAN トンネリングを使用する SR-IOV 用のコンポーザブルロールを設定する方法について説明します。コンポーザブルロールの作成およびデプロイのプロセスには、以下の作業が含まれます。
-
role_data.yamlファイルのローカルコピーで新規ロールを定義します。 -
network_environment.yamlファイルを編集して、この新規ロールを追加します。 - 更新したロールセットでオーバークラウドをデプロイします。
以下の例では、ComputeSriov は、コンピュートノード用のコンポーザブルロールで、サポートされている NIC が搭載されたノードでのみ SR-IOV を有効にします。Red Hat OpenStack Platform によって提供される既存のデフォルトロールセットは、/home/stack/roles_data.yaml ファイルに保管されます。
3.1.1. SR-IOV 用のコンポーザブルロールを作成するための roles_data.yaml の編集
roles_data.yaml ファイルを /home/stack/templates ディレクトリーにコピーして、新しい ComputeSriov ロールを追加します。
- name: ComputeSriov
CountDefault: 1
HostnameFormatDefault: compute-sriov-%index%
disable_upgrade_deployment: True
ServicesDefault:
- OS::TripleO::Services::CACerts
- OS::TripleO::Services::CephClient
- OS::TripleO::Services::CephExternal
- OS::TripleO::Services::Timezone
- OS::TripleO::Services::Ntp
- OS::TripleO::Services::Snmp
- OS::TripleO::Services::Sshd
- OS::TripleO::Services::NovaCompute
- OS::TripleO::Services::NovaLibvirt
- OS::TripleO::Services::Kernel
- OS::TripleO::Services::ComputeNeutronCorePlugin
- OS::TripleO::Services::ComputeNeutronOvsAgent
- OS::TripleO::Services::ComputeCeilometerAgent
- OS::TripleO::Services::ComputeNeutronL3Agent
- OS::TripleO::Services::ComputeNeutronMetadataAgent
- OS::TripleO::Services::TripleoPackages
- OS::TripleO::Services::TripleoFirewall
- OS::TripleO::Services::NeutronSriovAgent
- OS::TripleO::Services::OpenDaylightOvs
- OS::TripleO::Services::SensuClient
- OS::TripleO::Services::FluentdClient
- OS::TripleO::Services::AuditD
- OS::TripleO::Services::Collectd3.1.2. first-boot.yaml の編集
tunedの設定で CPU アフィニティーを指定するように設定します。compute_kernel_args: type: OS::Heat::SoftwareConfig properties: config: str_replace: template: | #!/bin/bash set -x FORMAT=$COMPUTE_HOSTNAME_FORMAT if [[ -z $FORMAT ]] ; then FORMAT="compute" ; else # Assumption: only %index% and %stackname% are the variables in Host name format FORMAT=$(echo $FORMAT | sed 's/\%index\%//g' | sed 's/\%stackname\%//g') ; fi if [[ $(hostname) == *$FORMAT* ]] ; then # Install the tuned package yum install -y tuned-profiles-cpu-partitioning tuned_conf_path="/etc/tuned/cpu-partitioning-variables.conf" if [ -n "$TUNED_CORES" ]; then grep -q "^isolated_cores" $tuned_conf_path if [ "$?" -eq 0 ]; then sed -i 's/^isolated_cores=.*/isolated_cores=$TUNED_CORES/' $tuned_conf_path else echo "isolated_cores=$TUNED_CORES" >> $tuned_conf_path fi tuned-adm profile cpu-partitioning fi sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"/\1 $KERNEL_ARGS"/g' -i /etc/default/grub ; grub2-mkconfig -o /etc/grub2.cfg reboot fi初期ブートパラメーターを設定します。
params: $KERNEL_ARGS: {get_param: ComputeKernelArgs} $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat} $TUNED_CORES: {get_param: HostIsolatedCoreList}
3.1.3. post-install.yaml の編集
tunedの設定で CPU アフィニティーを指定するように設定します。ExtraConfig: type: OS::Heat::SoftwareConfig properties: group: script config: str_replace: template: | #!/bin/bash set -x FORMAT=$COMPUTE_HOSTNAME_FORMAT if [[ -z $FORMAT ]] ; then FORMAT="compute" ; else # Assumption: only %index% and %stackname% are the variables in Host name format FORMAT=$(echo $FORMAT | sed 's/\%index\%//g' | sed 's/\%stackname\%//g') ; fi if [[ $(hostname) == *$FORMAT* ]] ; then tuned_service=/usr/lib/systemd/system/tuned.service grep -q "network.target" $tuned_service if [ "$?" -eq 0 ]; then sed -i '/After=.*/s/network.target//g' $tuned_service fi grep -q "Before=.*network.target" $tuned_service if [ ! "$?" -eq 0 ]; then grep -q "Before=.*" $tuned_service if [ "$?" -eq 0 ]; then sed -i 's/^\(Before=.*\)/\1 network.target openvswitch.service/g' $tuned_service else sed -i '/After/i Before=network.target openvswitch.service' $tuned_service fi fi systemctl daemon-reload fi params: $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat}
3.1.4. network-environment.yaml の編集
ComputeSriov ロールを含む、SR-IOV 用のカスタムリソースを
resource_registry下に追加します。resource_registry: # Specify the relative/absolute path to the config files you want to use for override the default. OS::TripleO::ComputeSriov::Net::SoftwareConfig: nic-configs/compute-sriov.yaml OS::TripleO::Controller::Net::SoftwareConfig: nic-configs/controller.yaml OS::TripleO::Compute::Net::SoftwareConfig: nic-configs/compute.yaml OS::TripleO::Services::NeutronSriovAgent: /usr/share/openstack-tripleo-heat-templates/puppet/services/neutron-sriov-agent.yaml OS::TripleO::NodeUserData: first-boot.yaml OS::TripleO::NodeExtraConfigPost: post-install.yaml
parameter_defaultsの下でトンネルの種別を無効にして (値を""に設定)、ネットワーク種別をvlanに設定します。NeutronTunnelTypes: "" NeutronNetworkType: 'vlan'
parameter_defaultsの下で、Open vSwitch の物理ネットワークをブリッジマッピングに設定します。NeutronBridgeMappings: 'tenant:br-link'
parameter_defaultsの下で、OpenStack Networking ML2 および Open vSwitch VLAN のマッピング範囲を指定します。NeutronNetworkVLANRanges: 'tenant:420:420,tenant:421:421'
この例では、物理ネットワーク (
tenant) 上の VLAN 範囲を設定していますparameter_defaultsの下で、SR-IOV の設定パラメーターを指定します。SR-IOV メカニズムドライバー (
sriovnicswitch) を有効化します。NeutronMechanismDrivers: "openvswitch,sriovnicswitch"
Compute の
pci_passthrough_whitelistパラメーターを設定し、SR-IOV インターフェース用のdevnameを指定します。ホワイトリストにより、仮想マシンが利用可能な PCI デバイスが設定されます。NovaPCIPassthrough: - devname: "ens2f1" physical_network: "tenant"物理ネットワークと SR-IOV インターフェースを
PHYSICAL_NETWORK:PHYSICAL DEVICEの形式で指定します。サーバー上にある
network_vlan_rangesに表示されている物理ネットワークにはすべて、各エージェントの適切なインターフェースへのマッピングが必要です。NeutronPhysicalDevMappings: "tenant:ens2f1"
この例では、
physical_network名にtenantを使用しています。各 SR-IOV インターフェースに確保する Virtual Function (VF) の数を指定します。
NeutronSriovNumVFs: "ens2f1:5"
この例では、SR-IOV インターフェース用に 5 つの VF を確保しています。
注記NFV を実装した Red Hat OpenStack Platform で現在サポートされている VF 数は 30 以下となっています。
parameter_defaultsの下で、ホストのプロセス用のメモリーを確保します。NovaReservedHostMemory: "2048"
parameter_defaultsの下で、仮想マシンのプロセス用に確保する物理 CPU コアのコンマ区切りリストまたは範囲を指定します。NovaVcpuPinSet: "4,20,5,21,6,22,7,23"
parameter_defaultsの下で、最も制約の多いフィルターからリストして、ノードのフィルタリングプロセスをさらに効率化します。コンピュートは、フィルターの配列を使用してノードをフィルタリングします。これらのフィルターは、リスト順に適用されます。
NovaSchedulerDefaultFilters: ['AvailabilityZoneFilter','RamFilter','ComputeFilter','ComputeCapabilitiesFilter','ImagePropertiesFilter','ServerGroupAntiAffinityFilter','ServerGroupAffinityFilter','PciPassthroughFilter','NUMATopologyFilter']
parameter_defaultsの下で、ComputeKernelArgsパラメーターを追加して、初期ブート時にそれらのパラメーターがデフォルトのgrubファイルに追加されるようにします。ComputeKernelArgs: "default_hugepagesz=1GB hugepagesz=1G hugepages=32 iommu=pt intel_iommu=on"
注記DPDK インスタンスに関連付けられたフレーバーには
hw:mem_page_size=1GBを追加する必要があります。このように設定しなかった場合には、そのインスタンスには DHCP による割り当ては行われません。parameter_defaultsの下に、チューニングする物理 CPU コアの一覧または範囲を指定します。指定の引数は、tuned
cpu-partitioningプロファイルに追加されます。HostIsolatedCoreList: "2,4,6,8,10,12,14,18,20,22,24,26,28,30"
3.1.5. controller.yaml の編集
分離されたネットワーク用のインターフェースを作成します。
- type: interface name: ens1f1 use_dhcp: false dns_servers: {get_param: DnsServers} -このインターフェースに VLAN を割り当てます。
- type: vlan vlan_id: {get_param: InternalApiNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: InternalApiIpSubnet} - type: vlan vlan_id: {get_param: TenantNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: TenantIpSubnet} - type: vlan vlan_id: {get_param: StorageNetworkVlanID} device: bond_api addresses: - ip_netmask: {get_param: StorageIpSubnet} - type: vlan vlan_id: {get_param: StorageMgmtNetworkVlanID} device: bond_api addresses: - ip_netmask: {get_param: StorageMgmtIpSubnet} - type: vlan vlan_id: {get_param: ExternalNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: ExternalIpSubnet} routes: - default: true next_hop: {get_param: ExternalInterfaceDefaultRoute}Compute ノードに接続する OVS ブリッジを作成します。
- type: ovs_bridge name: br-link use_dhcp: false members: - type: interface name: ens2f1
3.1.6. compute.yaml の編集
デフォルトの compute.yaml ファイルから compute-sriov.yaml を作成します。これは、ComputeSriov コンポーザブルロールを使用するコンピュートノードのパラメーターを制御するファイルです。
分離されたネットワーク用のインターフェースを作成します。
- type: interface name: ens1f1 use_dhcp: false dns_servers: {get_param: DnsServers} -このインターフェースに VLAN を割り当てます。
- type: vlan vlan_id: {get_param: InternalApiNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: InternalApiIpSubnet} - type: vlan vlan_id: {get_param: TenantNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: TenantIpSubnet} - type: vlan vlan_id: {get_param: StorageNetworkVlanID} device: ens1f1 addresses: - ip_netmask: {get_param: StorageIpSubnet} -
3.1.7. overcloud_deploy.sh スクリプトを実行します。
以下の例では、コンポーザブルロールを使用する openstack overcloud deploy の Bash スクリプトを定義しています。
# #!/bin/bash openstack overcloud deploy --templates \ -r /home/stack/templates/roles_data.yaml \ -e /usr/share/openstack-tripleo-heat-templates/environments/network-isolation.yaml \ -e /home/stack/ospd-11-vlan-dpdk-sriov-single-port-composable-roles/network-environment.yaml
/home/stack/templates/roles_data.yaml は、更新された roles_data.yaml ファイルの場所です。このファイルが SR-IOV のコンポーザブルロールを定義します。
3.2. SR-IOV 用のフレーバーの作成とインスタンスのデプロイ
NFV を実装する Red Hat OpenStack Platform デプロイメントの SR-IOV の設定を完了した後には、以下の手順に従ってフレーバーを作成してインスタンスをデプロイします。
アグリゲートグループを作成して、SR-IOV 用にホストを追加します。
# openstack aggregate create --zone=sriov sriov # openstack aggregate add host sriov compute-sriov-0.localdomain
フレーバーを作成します。
# openstack flavor create m1.medium_huge_4cpu --ram 4096 --disk 150 --vcpus 4
このコマンドでは、
m1.medium_huge_4cpuはフレーバー名、4096は MB 単位のメモリー容量、150は GB 単位のディスク容量 (デフォルトでは 0 G)、4は仮想 CPU 数を設定しています。フレーバーの追加のプロパティーを設定します。
# openstack flavor set --property hw:cpu_policy=dedicated --property hw:mem_page_size=large --property hw:numa_nodes=1 --property hw:numa_mempolicy=preferred --property hw:numa_cpus.0=0,1,2,3 --property hw:numa_mem.0=4096 m1.medium_huge_4cpu
このコマンドでは、
m1.medium_huge_4cpuはフレーバー名を指定しており、残りはそのフレーバーのその他のプロパティーを設定しています。インスタンスをデプロイします。
# openstack server create --flavor m1.medium_huge_4cpu --availability-zone sriov --image rhel_7.3 --nic port-id=<direct-port-id> sriov_vm
このコマンドでは、
m1.medium_huge_4cpuはフレーバーの名前または ID、sriovはサーバーのアベイラビリティーゾーン、rhel_7.3はインスタンスの作成に使用するイメージ (名前または ID)、<direct-port-id>はサーバー上の NIC、sriov_vmはインスタンス名を設定します。
これで、NFV ユースケースの SR-IOV 向けインスタンスのデプロイが完了しました。