lbv2启用loadbalancer ssl卸载服务

安装lbv2

首先是安装lbv2的流程,如果是p之后的版本lbaas应该是默认v2的:
1.控制节点:yum install -y openstack-neutron-lbaas
2.修改配置文件(采用octavia参考config-lbaas):
neutron.conf:

[defualt]
service_plugins = [existing service plugins],neutron_lbaas.services.loadbalancer.plugin.LoadBalancerPluginv2
[service_providers]
service_provider = LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default

lbaas_agent.ini:

interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver

3.更新数据库:neutron-db-manage —subproject neutron-lbaas upgrade head
4.启动agent:

systemctl enable neutron-lbaasv2-agent
systemctl start neutron-lbaasv2-agent
systemctl restart neutron-server

5.安装dashboard:

git clone https://git.openstack.org/openstack/neutron-lbaas-dashboard -b stable/pike
cd neutron-lbaas-dashboard
python setup.py install
cp neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py /usr/share/openstack-dashboard/openstack_dashboard/local/enabled/
./manage.py collectstatic
./manage.py compress
OPENSTACK_NEUTRON_NETWORK = {
'enable_lb': True,
...
}
systemctl restart httpd

安装barbican

barbican是openstack单独的一个组件,主要用于密钥管理(key manage)。目前有很多组件使用了barbican的密钥管理。对于lbaas来讲,可以使用barbican为loadbalancer提供ssl的密钥管理。

接下来记录下barbican的安装流程:具体的步骤可以参考:barbican-install

但上面的这个步骤,有几处注意一下:
1.编辑/etc/httpd/conf.d/wsgi-barbican.conf 文件时,我使用VirtualHost 0.0.0.0:9311替换了VirtualHost [::1]:9311并且在/etc/httpd/conf/ports文件里添加了Listen 0.0.0.0:9311才使得httpd加载barbican服务。还有如下修改:

vim /etc/httpd/conf.d/wsgi-barbican.conf
<VirtualHost 0.0.0.0:9311>
ServerName 192.168.99.2
ErrorLog "/var/log/httpd/barbican_wsgi_main_error_ssl.log"
LogLevel debug
ServerSignature Off
CustomLog "/var/log/httpd/barbican_wsgi_main_access_ssl.log" combined
<Directory "/usr/lib/python2.7/site-packages/barbican">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Allow from all
Require all granted
</Directory>
WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess barbican-api display-name=barbican-api group=barbican processes=2 threads=8 user=barbican
WSGIProcessGroup barbican-api
WSGIScriptAlias / "/usr/lib/python2.7/site-packages/barbican/api/app.wsgi"
WSGIPassAuthorization On
</VirtualHost>

2.编辑/etc/barbican/barbican.conf,修改和增加如下配置:

[DEFAULT]
transport_url = rabbit://guest:guest@controller
host_href = http://xxx.xxx.xxx.xxx:9311
log_file = /var/log/barbican/api.log

3.检查barbican服务是否启动,可以先通过以下命令查看是否者报错:

openstack secret list
+--------------------------------------------------------------------------+-------------+---------------------------+--------+-----------------------------+-----------+------------+-------------+------+------------+
| Secret href | Name | Created | Status | Content types | Algorithm | Bit length | Secret type | Mode | Expiration |
+--------------------------------------------------------------------------+-------------+---------------------------+--------+-----------------------------+-----------+------------+-------------+------+------------+
| http://192.168.99.2:9311/v1/secrets/8a1b6444-216e-44a7-a049-8b15d83dcdc1 | mysecret | 2018-03-25T17:40:58+00:00 | ACTIVE | {u'default': u'text/plain'} | aes | 256 | opaque | cbc | None

若报错,可以再查看9311端口是否监听,以及查看日志/var/log/barbican/api.log和/var/log/httpd/:

netstat -lnp | grep 9311
tcp 0 0 0.0.0.0:9311 0.0.0.0:* LISTEN 15773/httpd

4.允许外部访问9311端口:

iptables -I INPUT -p tcp --dport 9311 -j ACCEPT

lbv2启用ssl卸载服务

ssl卸载服务(TERMINATED_HTTPS):lbv2的loadbalancer可以对外提供https服务,对于到来的流量会将ssl卸载,并提供给内部的http服务器。具体的步骤可以参考:tls-balancer-install

上面的步骤对于现在的版本,有些过时了,所以有以下几处注意的:
1.首先,barbican客户端属于将要废弃的,所以使用openstack客户端命令,例如创建secret(其它步骤类似):

openstack secret store --payload-content-type='text/plain' --name='certificate' --payload="$(cat server.crt)"

2.修改/etc/neutron/neutron_lbaas.conf不能按照官方的配置auth_uri:

auth_url = 192.168.99.2:5000/v2.0
auth_version = 3

3.创建安全组规则的命令,也废弃了,我采用的neutron客户端(default是对象组名,这里简略,应采用对象组id):

neutron neutron security-group-rule-create --direction ingress --protocol tcp --port-range-min 22 --port-range-max 22 default
neutron neutron security-group-rule-create --direction egress --protocol tcp --port-range-min 22 --port-range-max
22 default
neutron security-group-rule-create --direction ingress --protocol icmp default

除此之外,还有好些命令都已过时,使用的时候,最好先了解命令参数的意思,然后正确使用。

总结

以上是lbv2启用ssl卸载服务的步骤,并没有详细叙述安装的细节,因为官方安装步骤都有,重要的是指出安装的几处坑,避免下次安装的时候再次踩坑。当然,不得不提的是Octavia项目将会取代lbv2,也就是说如果换成Octavia,前面所提到的安装配置,就要以Octavia相关的为准。

个人分析,欢迎指正,若转载请注明出处!