使用 OpenStack 和 Kolla Ansible 安装 Contrail
我们建议使用 Contrail 命令将计算节点添加到大多数 Contrail 网络部署中的现有 Contrail 群集。请参阅使用 Contrail 命令将新的计算节点添加到现有 Contrail 群集。
本文档中的过程只能由在不使用 Contrail 命令 GUI 的环境中具有丰富 YAML 文件专业知识的网络管理员执行。
本主题的目标是使用 Kolla Ansible 剧本 contrail-kolla-ansible
安装 OpenStack 的 Contrail 网络。
Kolla是一个OpenStack项目,它提供了为OpenStack服务构建容器映像的工具。Kolla Ansible 提供部署 Kolla 映像的 Ansible 剧本。
该 contrail-kolla-ansible
手册与 OpenStack 和 Contrail 网络容器的安装协同 contrail-ansible-deployer
工作。
请参阅使用 Contrail 命令和实例安装 Contrail 群集,以使用 Contrail 命令部署 Contrail 群集 。
按照以下过程部署 Kolla 容器,并使用以下命令部署 contrail-ansible-deployer
Contrail 网络容器contrail-kolla-ansible
:
设置基本主机
更新 CentOS 和内核版本。有关受支持平台的列表,请参阅 https://www.juniper.net/documentation/en_US/release-independent/contrail/topics/reference/contrail-supported-platforms.pdf。
虚拟路由器与主机内核有 依赖 关系。
要设置基本主机:
从 Contrail 下载页面下载 Ansible Deployer 安装程序包。
安装 Ansible。
yum -y install epel-release
yum -y install git ansible-2.7.10
安装 python-pip。
yum install -y python-pip
运行以下命令。
yum -y remove PyYAML python-requests
pip install PyYAML requests
解压缩 tgz 文件。
- tar xvf contrail-ansible-deployer-19<xx>.<NN>.tgz
实例.yaml 位于contrail-ansible-deployer/config/
使用以下准则在文件 instances.yaml 中配置 Contrail 和 Kolla 参数:
提供商配置 (
provider_config
) 部分是指将托管 Contrail 群集的云提供商,并包含与提供商相关的所有参数。对于裸机服务器,提供商为bms
。本节
kolla_globals
涉及 OpenStack 服务。有关所有可能kolla_globals
的详细信息,请参阅 https://github.com/Juniper/contrail-kolla-ansible/.../globals.yml。其他 Kolla 配置 (
contrail-kolla-ansible
) 可以作为 。contrail_additions
有关 Kolla 的所有可能contrail_additions
的详细信息,请参阅 https://github.com/Juniper/contrail-kolla-ansible/.../all.yml。该
contrail_configuration
部分包含 Contrail 服务的参数。CONTAINER_REGISTRY
指定要从中提取 Contrail 容器的注册表。如果要构建自己的容器,则可以将其设置为本地 Docker 注册表。如果未指定注册表,它将尝试从 Docker 中心拉取容器。如果指定了自定义注册表,则还要在 下
kolla_globals
contrail_docker_registry
指定相同的注册表。CONTRAIL_VERSION
,如果未指定,将默认为“最新”标记。有关 的所有
contrail_configuration
可能参数的详细信息,请参阅 https://github.com/tungstenfabric/tf-container-builder/blob/master/containers/base/common.sh。您必须在 instances.yaml 文件中指定 。roles否则,安装过程将失败。
如果每个主机都有特定于主机的值,例如,群集中用于“network_interface”的接口名称不同,请使用 多节点 OpenStack HA 和 Contrail(多接口)配置示例中的示例配置。
许多参数会自动派生为合理的默认值(第一个配置的工作原理)。如果需要,可以显式指定变量以覆盖派生值。查看代码以查看派生逻辑。
示例:实例.yaml
此示例是单节点、单接口、一体化群集的最低配置。
provider_config: bms: ssh_pwd: <password> ssh_user: root ntpserver: <IP NTP server> domainsuffix: local instances: bms1: provider: bms ip: <IP BMS> roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: vrouter: openstack: openstack_compute: contrail_configuration: RABBITMQ_NODE_PORT: 5673 AUTH_MODE: keystone KEYSTONE_AUTH_URL_VERSION: /v3 kolla_config: kolla_globals: enable_haproxy: no kolla_passwords: keystone_admin_password: <Keystone admin password>
示例:实例.yaml
此示例是针对单节点、单接口、一体化群集的更详细的配置。
provider_config: bms: ssh_pwd: <password> ssh_user: root ntpserver: <IP NTP server> domainsuffix: local instances: bms1: provider: bms ip: <IP BMS> roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: vrouter: openstack: openstack_compute: global_configuration: CONTAINER_REGISTRY: <Registry FQDN/IP>:<Registry Port> REGISTRY_PRIVATE_INSECURE: True contrail_configuration: CONTRAIL_VERSION: latest CLOUD_ORCHESTRATOR: openstack VROUTER_GATEWAY: <IP gateway> RABBITMQ_NODE_PORT: 5673 PHYSICAL_INTERFACE: <interface name> AUTH_MODE: keystone KEYSTONE_AUTH_URL_VERSION: /v3 kolla_config: kolla_globals: kolla_internal_vip_address: <Internal VIP> contrail_api_interface_address: <Contrail API Addr> enable_haproxy: no kolla_passwords: keystone_admin_password: <Keystone Admin Password>
从 contrail-ansible-deployer 文件夹中运行以下命令:
ansible-playbook -e orchestrator=openstack -i inventory/ playbooks/configure_instances.yml
ansible-playbook -i inventory/ playbooks/install_openstack.yml
ansible-playbook -e orchestrator=openstack -i inventory/ playbooks/install_contrail.yml
打开 Web 浏览器并键入 https://contrail-server-ip:8143 以访问 Contrail Web UI。
默认登录用户名为 admin。使用在步骤 6 中输入的相同密码
多节点 OpenStack HA 和 Contrail 的多接口配置示例
这是高可用性 OpenStack 和 Contrail 网络的多接口、多节点部署的配置示例。使用此示例配置特定于系统的参数。
有关更多信息或最近的更新,请参阅 github 主题多 节点 OpenStack HA 和 Contrail(多接口)的配置示例。
配置示例 — 多接口
provider_config: bms: ssh_pwd: <Pwd> ssh_user: root ntpserver: <NTP Server> domainsuffix: local instances: bms1: provider: bms ip: <BMS1 IP> roles: openstack: bms2: provider: bms ip: <BMS2 IP> roles: openstack: bms3: provider: bms ip: <BMS3 IP> roles: openstack: bms4: provider: bms ip: <BMS4 IP> roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: bms5: provider: bms ip: <BMS5 IP> roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: bms6: provider: bms ip: <BMS6 IP> roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: bms7: provider: bms ip: <BMS7 IP> roles: vrouter: PHYSICAL_INTERFACE: <Interface name> VROUTER_GATEWAY: <Gateway IP> openstack_compute: bms8: provider: bms ip: <BMS8 IP> roles: vrouter: # Add following line for TSN Compute Node TSN_EVPN_MODE: True openstack_compute: contrail_configuration: CLOUD_ORCHESTRATOR: openstack KEYSTONE_AUTH_URL_VERSION: /v3 IPFABRIC_SERVICE_HOST: <Service Host IP> # Add following line for TSN Compute Node TSN_NODES: <TSN NODE IP List> # For EVPN VXLAN TSN ENCAP_PRIORITY: "VXLAN,MPLSoUDP,MPLSoGRE" PHYSICAL_INTERFACE: <Interface name> kolla_config: kolla_globals: kolla_internal_vip_address: <Internal VIP> kolla_external_vip_address: <External VIP> contrail_api_interface_address: <Contrail API IP> kolla_passwords: keystone_admin_password: <Keystone Admin Password>
多节点 OpenStack HA 和 Contrail 的单接口配置示例
这是高可用性 OpenStack 和 Contrail 网络的多节点、单接口部署的配置示例。使用此示例配置特定于系统的参数。
有关更多信息或最近的更新,请参阅 github 主题多 节点 OpenStack HA 和 Contrail(单界面)的配置示例。
配置示例 — 单接口
provider_config: bms: ssh_pwd: <password> ssh_user: root ntpserver: xx.xx.x.xx domainsuffix: local instances: centos1: provider: bms ip: ip-address roles: openstack: centos2: provider: bms ip: ip-address roles: openstack: centos3: provider: bms ip: ip-address roles: openstack: centos4: provider: bms ip: ip-address roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: centos5: provider: bms ip: ip-address roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: centos6: provider: bms ip: ip-address roles: config_database: config: control: analytics_database: analytics: analytics_alarm: analytics_snmp: webui: centos7: provider: bms ip: ip-address roles: vrouter: openstack_compute: centos8: provider: bms ip: ip-address roles: vrouter: openstack_compute: contrail_configuration: CONTRAIL_VERSION: <contrail_version> CONTROLLER_NODES: ip-addresses separated by comma CLOUD_ORCHESTRATOR: openstack RABBITMQ_NODE_PORT: 5673 VROUTER_GATEWAY: gateway-ip-address PHYSICAL_INTERFACE: eth1 IPFABRIC_SERVICE_IP: ip-address KEYSTONE_AUTH_HOST: ip-address KEYSTONE_AUTH_URL_VERSION: /v3 kolla_config: kolla_globals: kolla_internal_vip_address: ip-address contrail_api_interface_address: ip-address network_interface: "eth1" enable_haproxy: "yes" kolla_passwords: keystone_admin_password: <password>
替换为 <contrail_version> 适用于您的 Contrail 版本的正确 contrail_container_tag
值。相应的 contrail_container_tag
值列在 README Access to Contrail Registry 19XX 中。
常见问题
本节介绍一些常见的错误情况,并提供有关如何解决错误情况的指导。
- 使用主机特定参数
- 无法访问专用注册表中的容器
- 错误:无法插入路由器内核模块
- vrouter 未指定 OpenStack 时的致命错误
- 需要在单个 OpenStack 群集上实现 HAProxy 和虚拟 IP
- 使用 kolla_toolbox 容器运行 OpenStack 命令
使用主机特定参数
您可能会遇到需要指定特定于主机的参数的情况,例如,群集中不同服务器的接口名称不同。在这种情况下,您可以在每个角色下指定单独的名称,更具体的设置优先。
例如,如果角色“openstack”下没有“network_interface”设置,例如“bms1”,那么它将从全局变量中获取其设置。
有关扩展示例,请访问: 多节点 OpenStack HA 和 Contrail 的配置示例。
无法访问专用注册表中的容器
您可能遇到从名为 CONTAINER_REGISTRY 的专用注册表拉取的容器无法访问的情况。
若要解决此问题,请检查以确保REGISTRY_PRIVATE_INSECURE设置为 True。
错误:无法插入路由器内核模块
您可能会遇到以下情况:虚拟路由器模块未安装在计算节点上,虚拟路由器容器处于错误状态,并且错误显示在 Docker 日志中。
[srvr5] ~ # docker logs vrouter_vrouter-kernel-init_1 /bin/cp: cannot create regular file '/host/bin/vif': No such file or directory INFO: Load kernel module for kver=3.10.0 INFO: Modprobing vrouter /opt/contrail/vrouter-kernel-modules/3.10.0-957.11.6.el7.x86_64/vrouter.ko total used free shared buff/cache available Mem: 62G 999M 55G 9.1M 5.9G 60G Swap: 0B 0B 0B total used free shared buff/cache available Mem: 62G 741M 61G 9.1M 923M 61G Swap: 0B 0B 0B insmod: ERROR: could not insert module /opt/contrail/vrouter-kernel-modules/3.10.0-957.11.6.el7.x86_64/vrouter.ko: Unknown symbol in module ERROR: Failed to insert vrouter kernel module
在此版本中,vrouter 模块要求主机内核版本为 3.10.0-957.11.6.el7.x86_64。若要获取此内核版本,请在运行预配之前,在目标节点上安装内核版本。
yum -y install kernel-3.10.0-957.11.6.el7.x86_64 yum update reboot
vrouter 未指定 OpenStack 时的致命错误
当需要在没有nova-compute的情况下预配vrouter时,您可能会遇到致命错误。
2018-03-21 00:47:16,884 p=16999 u=root | TASK [iscsi : Ensuring config directories exist] ******************** 2018-03-21 00:47:16,959 p=16999 u=root | fatal: [ip-address]: FAILED! => {"msg": "The conditional check 'inventory_hostname in groups['compute'] or inventory_hostname in groups['storage']' failed. The error was: error while evaluating conditional (inventory_hostname in groups['compute'] or inventory_hostname in groups['storage']): Unable to look up a name or access an attribute in template string ({% if inventory_hostname in groups['compute'] or inventory_hostname in groups['storage'] %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like '-': argument of type 'StrictUndefined' is not iterable\n\nThe error appears to have been in '/root/contrail-kolla- ansible/ansible/roles/iscsi/tasks/config.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ensuring config directories exist\n ^ here\n"} 2018-03-21 00:47:16,961 p=16999 u=root | to retry, use: --limit @/root/contrail-ansible- deployer/playbooks/install_contrail.retry
有一种用例是,需要在没有 nova-compute 的情况下配置虚拟路由器。因此,当指定“vrouter”角色时,不会自动推断“openstack_compute”。要解决此问题,需要明确声明“openstack_compute”角色以及“vrouter”。
有关此用例的更多信息,请参阅错误 #1756133。
需要在单个 OpenStack 群集上实现 HAProxy 和虚拟 IP
默认情况下,所有 OpenStack 服务都会侦听 config/instances.yaml 中该部分中的kolla_globals
变量提供的 kolla_internal_vip_address/network_interface
IP 接口。在大多数情况下,这对应于 ctrl 数据网络,这意味着即使是 Horizon 现在也只能在 ctrl 数据网络上运行。Kolla在管理网络上提供对Horizon的访问的唯一方法是使用HAProxy和keepalived。启用激活需要 VRRP 的虚拟 IP,它不能是接口 IP。在使用 Kolla 配置参数时,如果不启用 keepalive,就无法启用 HAProxy。因此,您需要提供两个虚拟 IP 地址:一个在管理 () 上,一个在 ctrl-data-network (kolla_external_vip_address
kolla_internal_vip_address
) 上。使用此配置,可通过 在管理网络上kolla_external_vip_address
访问 Horizon。
使用 kolla_toolbox 容器运行 OpenStack 命令
运行 OpenStack 容器的基本主机上的目录/etc/kolla/kolla-toolbox
已挂载,可从容器内部kolla_toolbox
访问/var/lib/kolla/config_files
。如果在执行 OpenStack 命令时需要其他文件,例如命令openstack image create
需要映像文件,则可以将相关文件/etc/kolla/kolla-toolbox
复制到基本主机的目录中,并在容器中使用它们。
以下示例说明如何以这种方式运行 OpenStack 命令:
# ON BASE HOST OF OPENSTACK CONTROL NODE cd /etc/kolla/kolla-toolbox wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img docker exec -it kolla_toolbox bash # NOW YOU ARE INSIDE THE KOLLA_TOOLBOX CONTAINER (kolla-toolbox)[ansible@server1 /]$ source /var/lib/kolla/config_files/admin-openrc.sh (kolla-toolbox)[ansible@server1 /]$ cd /var/lib/kolla/config_files (kolla-toolbox)[ansible@server1 /var/lib/kolla/config_files]$ openstack image create cirros2 --disk-format qcow2 --public --container-format bare --file cirros-0.4.0-x86_64-disk.img +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | 443b7623e27ecf03dc9e01ee93f67afe | | container_format | bare | | created_at | 2018-03-29T21:37:48Z | | disk_format | qcow2 | | file | /v2/images/e672b536-0796-47b3-83a6-df48a5d074be/file | | id | e672b536-0796-47b3-83a6-df48a5d074be | | min_disk | 0 | | min_ram | 0 | | name | cirros2 | | owner | 371bdb766278484bbabf868cf7325d4c | | protected | False | | schema | /v2/schemas/image | | size | 12716032 | | status | active | | tags | | | updated_at | 2018-03-29T21:37:50Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ (kolla-toolbox)[ansible@server1 /var/lib/kolla/config_files]$ openstack image list +--------------------------------------+---------+--------+ | ID | Name | Status | +--------------------------------------+---------+--------+ | e672b536-0796-47b3-83a6-df48a5d074be | cirros2 | active | | 57e6620e-796a-40ee-ae6e-ea1daa253b6c | cirros2 | active | +--------------------------------------+---------+--------+