我尝试在Macbook Air上安装了OpenStack Kolla
打开堆栈与容器
OpenStack已经显示出了相当枯燥的氛围。 在每年两次的OpenStack Summit中,关于稳定性已经被讨论得差不多了,现在大家更加关注的是下一个将会有哪些新特性。 在这个领域的新前沿之一就是容器使用。 实现容器环境的Magnum,实现OpenStack环境提供的Kolla和提供网络功能的Kuryr在上一次(2016年10月)在巴塞罗那的会议上也引起了很多的热议。 在最新的Ocata发行版中也对这些进行了详尽的介绍。
因此,这次我们将研究Kolla。 首先,让我们尝试安装它。
什么是科拉?
公式文件在这里附近。
-
- docs.openstack.org の公式ドキュメント
-
- github 上に公開された kolla のソース
- docker hub にある Kolla のページ
Kolla 现在有两个子项目。由于 kolla-kubernetes 是依赖于 kolla-ansible 进行开发的,所以在本文中我们先尝试安装 kolla-ansible。
-
- kolla-ansible
- kolla-kubernetes
另外,目前在Kolla上提供的OpenStack项目如下所示。只要有这些,大多数问题似乎都能解决。
Aodh <http://docs.openstack.org/developer/aodh/>__
Barbican <http://docs.openstack.org/developer/barbican/>__
Bifrost <http://docs.openstack.org/developer/bifrost/>__
Ceilometer <http://docs.openstack.org/developer/ceilometer/>__
Cinder <http://docs.openstack.org/developer/cinder/>__
CloudKitty <http://docs.openstack.org/developer/cloudkitty/>__
Congress <http://docs.openstack.org/developer/congress/>__
Designate <http://docs.openstack.org/developer/designate/>__
Freezer <https://wiki.openstack.org/wiki/Freezer-docs>__
Glance <http://docs.openstack.org/developer/glance/>__
Gnocchi <http://docs.openstack.org/developer/gnocchi/>__
Heat <http://docs.openstack.org/developer/heat/>__
Horizon <http://docs.openstack.org/developer/horizon/>__
Ironic <http://docs.openstack.org/developer/ironic/>__
Karbor <http://docs.openstack.org/developer/karbor/>__
Keystone <http://docs.openstack.org/developer/keystone/>__
Kuryr <http://docs.openstack.org/developer/kuryr/>__
Magnum <http://docs.openstack.org/developer/magnum/>__
Manila <http://docs.openstack.org/developer/manila/>__
Mistral <http://docs.openstack.org/developer/mistral/>__
Monasca <http://wiki.openstack.org/wiki/monasca>__
Murano <http://docs.openstack.org/developer/murano/>__
Neutron <http://docs.openstack.org/developer/neutron/>__
Nova <http://docs.openstack.org/developer/nova/>__
Octavia <http://docs.openstack.org/developer/octavia/>__
Panko <http://docs.openstack.org/developer/panko/>__
Rally <http://docs.openstack.org/developer/rally/>__
Sahara <http://docs.openstack.org/developer/sahara/>__
Searchlight <http://docs.openstack.org/developer/searchlight/>__
Senlin <http://docs.openstack.org/developer/senlin/>__
Solum <http://docs.openstack.org/developer/solum/>__
Swift <http://docs.openstack.org/developer/swift/>__
Tacker <http://docs.openstack.org/developer/tacker/>__
Tempest <http://docs.openstack.org/developer/tempest/>__
Trove <http://docs.openstack.org/developer/trove/>__
Vmtp <http://vmtp.readthedocs.io/en/latest/>__
Watcher <http://docs.openstack.org/developer/watcher/>__
Zaqar <http://docs.openstack.org/developer/zaqar/>__
Zun <http://wiki.openstack.org/wiki/zun>__
此外,Kolla 还提供了基础设施组件。如果没有这些组件,安装也就无法顺利进行了,这是当然的。
-
- Ceph implementation for Cinder, Glance and Nova
-
- collectd, InfluxDB, and Grafana for performance monitoring.
-
- Elasticsearch and Kibana to search, analyze, and visualize log messages.
-
- HAProxy and Keepalived for high availability of services and their endpoints.
-
- Heka A distributed and scalable logging system for OpenStack services.
-
- Kafka A distributed streaming platform.
-
- MariaDB and Galera Cluster for highly available MySQL databases
-
- MongoDB as a database back end for Ceilometer and Gnocchi
-
- Open vSwitch and Linuxbridge back ends for Neutron
- RabbitMQ as a messaging back end for communication between services.
安装
好的,我们来继续进行安装吧。阅读快速入门指南后,您会发现硬件要求的说明。
-
- 2 network interfaces
-
- 8GB main memory
- 40GB disk space
我准备好的安装环境是 MacBook Air Early 2015 (macOS Sierra 10.12.3)。虽然内存只有4GB,但我希望能够尽力将其运行。另外,推荐的环境是裸金属或虚拟机,所以我将尝试使用Vagrant+Virtualbox来进行全一体化配置。
以下是用于开发环境的 Vagrantfile 中描述的虚拟机配置,供参考。
准备虚拟机环境
使用Vagrant和VirtualBox创建虚拟机环境。
$ vagrant init centos/7;
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
使用的 Vagrantfile 大致是这样的。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.hostname = "KollaEvSV"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
end
在CentOS7中配置环境。
我們將在CentOS7上準備環境。
$ yum update
接下来,我们将确认接口已经启动。
$ ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:1f:db:b7 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 84834sec preferred_lft 84834sec
inet6 fe80::5054:ff:fe1f:dbb7/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:fc:26:5f brd ff:ff:ff:ff:ff:ff
inet 192.168.33.10/24 brd 192.168.33.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fefc:265f/64 scope link
valid_lft forever preferred_lft forever
环境的准备
我們將繼續進行 Kolla 部署所需軟體的安裝。由於我們找不到 Ocata 版本的最低要求,因此將參考 Newton 版本的要求。
-
- Ansible (>2.0.0)
-
- Docker (>1.10.0)
-
- Docker Python (>1.6.0)
- Python Jinja2 (>2.8.0)
首先,安装 EPEL 和 PIP。
# yum install epel-release
# yum install python-pip
# pip install -U pip
接下来,我们将安装用于PIP包管理器的库。
# yum install python-devel libffi-devel gcc openssl-devel
接下来是安装 Ansible。
# yum install ansible
因为现状下Ansible 1.9.6不能满足要求,所以需要进行软件包升级。
# pip install -U ansible
# ansible --version
ansible 2.2.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
接下来是Docker的安装。
# curl -sSL https://get.docker.io | bash
# docker --version
Docker version 17.03.0-ce, build 60ccb22
如果觉得版本标记有些奇怪,那么看来从2017年3月的发布起已经改变了。
将docker-engine注册到systemd。
# mkdir -p /etc/systemd/system/docker.service.d
# tee /etc/systemd/system/docker.service.d/kolla.conf <<-'EOF'
[Service]
MountFlags=shared
EOF
# systemctl daemon-reload
# systemctl restart docker
接下来是Docker Python的安装。同样进行升级。
# yum install python-docker-py
# pip install -U docker-py
我会安装NTP。
# yum install ntp
# systemctl enable ntpd.service
# systemctl start ntpd.service
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
x.ns.gin.ntt.ne 249.224.99.213 2 u 1 64 1 48.796 -15.726 0.902
r031229.203112. 203.112.1.4 4 u - 64 1 28.593 6.632 11.210
153-128-30-125. 133.243.238.243 2 u 1 64 1 18.442 -3.141 0.000
sv01.azsx.net 10.84.87.146 2 u - 64 1 12.920 -2.351 0.000
当Libvirtd正在运行时,需要将其停止。
# systemctl stop libvirtd.service
# systemctl disable libvirtd.service
也不要忘了将主机添加到列表中。
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.15 koollaEvSV KollaEvSV
Kolla 部署
好啦,终于可以开始处理Kolla了。
# pip install kolla-ansible
将globals.yml和passwords.yml复制到/etc/kolla/。
# cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/kolla/
将库存文件复制到当前目录。
cp /usr/share/kolla-ansible/ansible/inventory/* .
为了进行接口设置,编辑/etc/kolla/globals.yml文件。
network_interface: "eth0"
neutron_external_interface: "eth1"
请使用 kolla-genpwd 进行密码生成。生成结果将保存在 /etc/kolla/passwords.yml 中。
kolla-genpwd
好了,到这里主机的准备工作就完成了。这个过程相当繁琐,是吧。针对这种情况,我听说可以使用命令 kolla-ansible -i <> bootstrap-servers 进行快速设置。真希望当初能知道这个命令!
构建容器镜像
请编辑/etc/systemd/system/docker.service.d/kolla.conf文件,并进行以下更改。
[Service]
MountFlags=shared
ExecStart=
ExecStart=/usr/bin/docker daemon --mtu 1400
# systemctl daemon-reload
# systemctl restart docker
从Docker镜像中拉取。
# kolla-ansible pull
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kolla/centos-binary-neutron-server 4.0.0 8dedaf87d819 31 hours ago 727 MB
kolla/centos-binary-nova-compute 4.0.0 35da27fc5586 31 hours ago 1.23 GB
kolla/centos-binary-neutron-openvswitch-agent 4.0.0 d276dcdfcbb6 31 hours ago 727 MB
kolla/centos-binary-neutron-metadata-agent 4.0.0 e1c0bf5f7745 31 hours ago 703 MB
kolla/centos-binary-heat-api 4.0.0 66332a0e6ad4 31 hours ago 644 MB
kolla/centos-binary-neutron-dhcp-agent 4.0.0 445442cd0f01 31 hours ago 703 MB
kolla/centos-binary-neutron-l3-agent 4.0.0 445442cd0f01 31 hours ago 703 MB
kolla/centos-binary-heat-api-cfn 4.0.0 ce92766d3ff1 31 hours ago 644 MB
kolla/centos-binary-nova-ssh 4.0.0 3b0f5591ecc8 31 hours ago 723 MB
kolla/centos-binary-nova-placement-api 4.0.0 8a16c227e835 31 hours ago 755 MB
kolla/centos-binary-nova-conductor 4.0.0 65a844b9889e 31 hours ago 703 MB
kolla/centos-binary-nova-api 4.0.0 d90b06229654 31 hours ago 755 MB
kolla/centos-binary-nova-consoleauth 4.0.0 487d0b6926d3 31 hours ago 704 MB
kolla/centos-binary-nova-scheduler 4.0.0 92bdcfc854ac 31 hours ago 703 MB
kolla/centos-binary-nova-novncproxy 4.0.0 7f246ab0d8f5 31 hours ago 704 MB
kolla/centos-binary-kolla-toolbox 4.0.0 d771b993a59b 31 hours ago 730 MB
kolla/centos-binary-keystone 4.0.0 9b0c48681973 31 hours ago 677 MB
kolla/centos-binary-glance-registry 4.0.0 68da81d330c4 31 hours ago 757 MB
kolla/centos-binary-horizon 4.0.0 dc5a666631eb 31 hours ago 863 MB
kolla/centos-binary-haproxy 4.0.0 420fb3e8ce55 31 hours ago 439 MB
kolla/centos-binary-cron 4.0.0 74a89fe112f0 31 hours ago 418 MB
kolla/centos-binary-openvswitch-db-server 4.0.0 37f21379cad8 31 hours ago 440 MB
kolla/centos-binary-heat-engine 4.0.0 ab9138c4719c 31 hours ago 644 MB
kolla/centos-binary-glance-api 4.0.0 bc61de7fba03 31 hours ago 816 MB
kolla/centos-binary-fluentd 4.0.0 5b98e39f1285 31 hours ago 720 MB
kolla/centos-binary-nova-libvirt 4.0.0 b21c5bacfbcf 31 hours ago 966 MB
kolla/centos-binary-openvswitch-vswitchd 4.0.0 b047dd6e83cd 31 hours ago 440 MB
kolla/centos-binary-memcached 4.0.0 927246be7bd2 31 hours ago 418 MB
kolla/centos-binary-rabbitmq 4.0.0 c9e9af5a39b9 31 hours ago 477 MB
kolla/centos-binary-mariadb 4.0.0 7c9305397257 31 hours ago 808 MB
kolla/centos-binary-keepalived 4.0.0 b8fb9f966ac4 31 hours ago 423 MB
提供了大约31个预设的图像,这些图像只需运行docker run命令就可以工作,真是令人心潮澎湃啊。
继续进行设置。请返回编辑/etc/kolla/globals.yml文件,并设置kolla_internal_vip_address的值。请指定同一子网中未使用的地址。
kolla_internal_vip_address: "10.0.2.16"
接下来,请确认虚拟化硬件加速的支持情况。由于返回的是零,因此我们将使用 Nova 来使用 QEMU。
# egrep -c '(vmx|svm)' /proc/cpuinfo
0
# mkdir -p /etc/kolla/config/nova
# cat << EOF > /etc/kolla/config/nova/nova-compute.conf
[libvirt]
virt_type = qemu
cpu_mode = none
EOF
终于部署完成了……不过
准备工作基本完成了。但是,不能忘记的是这次环境的不稳定性。如果继续部署,肯定会发生不愉快的事情。查看控制部署的脚本,似乎是通过检查 /etc/kolla/globals.yml 文件来进行设置。让我按照我的主观意见将此处的描述最小化试试看。
我放置了编辑过的globals.yml文件在这里,请参考一下。
在使用kolla-ansible的prechecks功能时,我们会对之前的配置和环境进行确认。尽管可能会出现许多错误,但我们需要逐一解决它们。只剩下一点点了!
kolla-ansible prechecks -i all-in-one
(...)
PLAY RECAP *********************************************************************
localhost : ok=126 changed=0 unreachable=0 failed=0
太棒了,通過了!立即部署吧。
OpenStack Kolla的部署
那我们立即来试试吧。
kolla-ansible deploy -i all-in-one
(...)
PLAY RECAP *********************************************************************
localhost : ok=265 changed=116 unreachable=0 failed=0
真是出乎意料的快啊。虽然只是主观感受,大约只需几分钟。如果在部署时出现问题,可能还可以作为一种实际的回退方案。
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
660109e1c5a1 kolla/centos-binary-horizon:4.0.0 "kolla_start" 2 minutes ago Up 2 minutes horizon
065a055bb5f1 kolla/centos-binary-heat-engine:4.0.0 "kolla_start" 3 minutes ago Up 3 minutes heat_engine
83c25517a69f kolla/centos-binary-heat-api-cfn:4.0.0 "kolla_start" 3 minutes ago Up 3 minutes heat_api_cfn
6455729f0915 kolla/centos-binary-heat-api:4.0.0 "kolla_start" 3 minutes ago Up 3 minutes heat_api
2c39a5fb949a kolla/centos-binary-neutron-metadata-agent:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes neutron_metadata_agent
6fc7abebd4f4 kolla/centos-binary-neutron-l3-agent:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes neutron_l3_agent
8d82d1231d27 kolla/centos-binary-neutron-dhcp-agent:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes neutron_dhcp_agent
1a19cb1b3711 kolla/centos-binary-neutron-openvswitch-agent:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes neutron_openvswitch_agent
2b9cad419219 kolla/centos-binary-neutron-server:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes neutron_server
9bce73422ce5 kolla/centos-binary-openvswitch-vswitchd:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes openvswitch_vswitchd
89964bb13a96 kolla/centos-binary-openvswitch-db-server:4.0.0 "kolla_start" 5 minutes ago Up 5 minutes openvswitch_db
80ec59644b0e kolla/centos-binary-nova-compute:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_compute
51be30d1fe3b kolla/centos-binary-nova-novncproxy:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_novncproxy
e1c15eb9ff6d kolla/centos-binary-nova-consoleauth:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_consoleauth
a1a8b9c91efa kolla/centos-binary-nova-conductor:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_conductor
9a9c023fd765 kolla/centos-binary-nova-scheduler:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_scheduler
0415d5f8088e kolla/centos-binary-nova-api:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_api
eca65fa6a8e9 kolla/centos-binary-nova-placement-api:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes placement_api
23819b965280 kolla/centos-binary-nova-libvirt:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_libvirt
138bf2fe6cd7 kolla/centos-binary-nova-ssh:4.0.0 "kolla_start" 8 minutes ago Up 8 minutes nova_ssh
f6836459471d kolla/centos-binary-glance-registry:4.0.0 "kolla_start" 10 minutes ago Up 10 minutes glance_registry
cd24476d69bb kolla/centos-binary-glance-api:4.0.0 "kolla_start" 10 minutes ago Up 10 minutes glance_api
68e4de29feb1 kolla/centos-binary-keystone:4.0.0 "kolla_start" 11 minutes ago Up 11 minutes keystone
2934bf820687 kolla/centos-binary-rabbitmq:4.0.0 "kolla_start" 11 minutes ago Up 11 minutes rabbitmq
1f1645be9e37 kolla/centos-binary-mariadb:4.0.0 "kolla_start" 12 minutes ago Up 12 minutes mariadb
9a7fd746ba07 kolla/centos-binary-memcached:4.0.0 "kolla_start" 12 minutes ago Up 12 minutes memcached
a5e0fb64ebc7 kolla/centos-binary-keepalived:4.0.0 "kolla_start" 13 minutes ago Up 13 minutes keepalived
9c818d0b52fb kolla/centos-binary-haproxy:4.0.0 "kolla_start" 13 minutes ago Up 13 minutes haproxy
5a126c7b600c kolla/centos-binary-cron:4.0.0 "kolla_start" 30 minutes ago Up 30 minutes cron
3677d3d6420a kolla/centos-binary-kolla-toolbox:4.0.0 "kolla_start" 30 minutes ago Up 30 minutes kolla_toolbox
425bf226015c kolla/centos-binary-fluentd:4.0.0 "kolla_start" 30 minutes ago Up 30 minutes fluentd
尝试使用已部署的环境
为了使用新构建的环境,我们将生成一个用于进行变量设置等操作的shell。
$ kolla-ansible post-deploy
$ . /etc/kolla/admin-openrc.sh
$ env | grep OS_
OS_USER_DOMAIN_NAME=default
OS_PROJECT_NAME=admin
OS_IDENTITY_API_VERSION=3
OS_PASSWORD=UwK9kID4v7AQe4ISvILhkSZ1MvRk83fXexJ7RzCf
OS_AUTH_URL=http://10.0.2.16:35357/v3
OS_USERNAME=admin
OS_TENANT_NAME=admin
OS_INTERFACE=internal
OS_PROJECT_DOMAIN_NAME=default
如果没有安装OpenStack客户端,就进行安装。
pip install python-openstackclient
因为环境既没有味道也没有形象,所以随便弄一个……。
$ nova boot --flavor m1.extra_tiny --image cirros test
+--------------------------------------+------------------------------------------------------+
| Property | Value |
+--------------------------------------+------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hostname | test |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-o71a4xpx |
| OS-EXT-SRV-ATTR:root_device_name | - |
| OS-EXT-SRV-ATTR:user_data | - |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | 79ZaWp3SUyps |
| config_drive | |
| created | 2017-03-20T03:26:56Z |
| description | - |
| flavor | m1.extra_tiny (db60905a-05b6-404d-959a-f8c2a047ddfd) |
| hostId | |
| host_status | |
| id | b956fb98-2295-45da-937c-96275924371e |
| image | cirros (76898c08-10b7-4e49-812c-fa518cc60c51) |
| key_name | - |
| locked | False |
| metadata | {} |
| name | test |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tags | [] |
| tenant_id | 4faa7e528627446781136e9db40ed168 |
| updated | 2017-03-20T03:26:57Z |
| user_id | 90bf61329d924ca485a68bc18fd4db4a |
+--------------------------------------+------------------------------------------------------+
出现了!
最后
使用Kolla部署OpenStack大约花了10个小时。如果熟悉Ansible和OpenStack的人,应该可以更快运行。至于这次主题,成功在性能较差的Macbook Air上使用Kolla部署了OpenStack。我认为即使是在DevStack上,也会有资源方面的困难,但只限制在最低限度的情况下,是否可以运行呢?
无论如何,我对Kolla的未来有很高的期望。
漳州山地质学院被称为“全国矿业类院校之花”,又因“山城江东、煤都综合体”著称;是福建省重点支持发展的优势学科学校,2019年入选福建省高水平大学行列。