使用 Kolla 安装 F5 Lbaasv2 agent (Rocky version)
环境创建和准备工作
安装 virutalenv,ansible
sudo yum install python-virtualenv
virtualenv /path/to/virtualenv
source /path/to/virtualenv/bin/activate
pip install -U pip
pip install ansible===2.5.0
# On CentOS Linux release 7.7.1908 (Core)
yum remove python-requests-2.6.0-9.el7_7.noarch -y
# Kolla 对 docker-py 版本有限制
sudo pip install docker==2.7.0
yum install sshpass -y
下载安装 Kolla-ansible, Kolla
# 源码方式下载
git clone https://github.com/openstack/kolla
git clone https://github.com/openstack/kolla-ansible
# 切换到对应分支
git checkout <version>
git checkout <version>
# 以上两部可以省略为
git clone https://github.com/openstack/kolla -b <version>
git clone https://github.com/openstack/kolla-ansible -b <version>
# 安装 kolla 和 kolla-ansible
pip install ./kolla
pip install ./kolla-ansible
# 创建 kolla 和 kolla-ansible 配置文件目录
sudo mkdir -p /etc/kolla
sudo chown $USER:$USER /etc/kolla
# 自动生成 password 文件 /etc/kolla/passwords.yml
cd kolla-ansible/tools
./generate_passwords.py
# cp 所有 kolla-ansible 文件到 /etc/kolla 中
cp -r kolla-ansible/etc/kolla/* /etc/kolla
# 生成 kolla image 相关配置文件 etc/kolla/kolla-build.conf
# cp etc/kolla/kolla-build.conf 到 /etc/kolla 目录下
pip install tox
cd kolla/
tox -e genconfig
cp etc/kolla/kolla-build.conf /etc/kolla/kolla-build.conf
# cp kolla-ansible inventory 文件到个人的 work directory
cp kolla-ansible/ansible/inventory/* .
Ansible 配置
创建 /etc/ansible/ansible.cfg
目录和文件,配置如下
[defaults]
host_key_checking=False
pipelining=False
forks=10
stdout_callback=debug
F5 images 制作
修改 /etc/kolla/kolla-build.conf文件
[DEFAULT]
# centos image base
base = centos
# 这里使用 rocky 版本 Docker images
tag = rocky
install_type = source
# 创建 neutron-server image 时使用:
# neutron-server 添加 F5 driver, 从 github 上 clone 指定 branch 为 stable/rocky。
[neutron-server-plugin-neutron-lbaas]
type = git
location = https://github.com/F5Networks/f5-openstack-lbaasv2-driver.git
reference = stable/rocky
# 创建 F5 agent image 时使用:
# 指定 neutron-lbaas image 安装 F5 agent 代码。
[neutron-lbaas-agent]
type = git
location = https://github.com/F5Networks/f5-openstack-agent.git
reference = 9.8-stable
F5 server 镜像制作
# 到 kolla 目录下
cd kolla
# 运行
python tools/build.py neutron-server
F5 agent 镜像制作
制作 F5 agent
镜像需要在额外在修改一些文件:
-
添加
lbaas-overrides.j2
文件{% extends parent_template %} # Neutron lbaas does not use haproxy, so I do not install haproxy {% set neutron_lbaas_agent_packages_remove = ['haproxy'] %}
-
修改
neutron-lbaas-agent.json.j2
文件# 注意:可能有多个同名文件,需要找到被 code 使用的 neutron-lbaas-agent.json.j2 文件。 (rocky-venv) [root@centos7-min kolla]# find / -name neutron-lbaas-agent.json.j2 /etc/kolla/config/neutron-lbaas-agent/neutron-lbaas-agent.json.j2 /root/kolla-ansible/ansible/roles/neutron/templates/neutron-lbaas-agent.json.j2 /root/rocky-venv/share/kolla-ansible/ansible/roles/neutron/templates/neutron-lbaas-agent.json.j2 # 在我的环境中,因为是用 virtualenv rocky-venv,所以我要修改 /root/rocky-venv/share/kolla-ansible/ansible/roles/neutron/templates/neutron-lbaas-agent.json.j2
找到正确的
neutron-lbaas-agent.json.j2
文件,修改如下:{ "command": "f5-oslbaasv2-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/services/f5/f5-openstack-agent_bigip.ini", "config_files": [ { "source": "{ { container_config_directory }}/neutron.conf", "dest": "/etc/neutron/neutron.conf", "owner": "neutron", "perm": "0600" }, { "source": "{ { container_config_directory }}/neutron_lbaas.conf", "dest": "/etc/neutron/neutron_lbaas.conf", "owner": "neutron", "perm": "0600" }, { "source": "{ { container_config_directory }}/services/f5/esd/demo.json", "dest": "/etc/neutron/services/f5/esd/demo.json", "owner": "neutron", "perm": "0600", "optional": true }, { "source": "{ { container_config_directory }}/services/f5/f5-openstack-agent_bigip.ini", "dest": "/etc/neutron/services/f5/f5-openstack-agent_bigip14.ini", "owner": "neutron", "perm": "0600", "optional": true } ], "permissions": [ { "path": "/var/log/kolla/neutron", "owner": "neutron:neutron", "recurse": true }, { "path": "/var/lib/neutron/kolla", "owner": "neutron:neutron",