Kolla

简介


Kolla是OpenStack Big Tent Governace下的一个项目,项目的目标是

To provide production-ready containers and deployment tools for operating
OpenStack clouds.

Kolla使用Docker容器和Anisble playbooks来实现这个目标。Kolla是开箱即用的,即使你是个新手也可以很快的使用kolla快速部署你的openstack集群。Kolla也允许你根据实际的需求来定制化的部署。

kolla目前已经可以部署以下openstack项目

可以部署的基础组件包括

Kolla体验


可以参照kolla官方文档https://github.com/openstack/kolla/blob/master/doc/quickstart.rst 进行部署。

Kolla解决的问题


可配置的灵活架构

可以看下默认的多节点架构

  1. # These initial groups are the only groups required to be modified. The
  2. # additional groups are for more control of the environment.
  3. [control]
  4. # These hostname must be resolvable from your deployment host
  5. control01
  6. control02
  7. control03
  8. # The above can also be specified as follows:
  9. #control[01:03] ansible_ssh_user=kolla
  10. # The network nodes are where your l3-agent and loadbalancers will run
  11. # This can be the same as a host in the control group
  12. [network]
  13. network01
  14. [compute]
  15. compute01
  16. # When compute nodes and control nodes use different interfaces,
  17. # you can specify "api_interface" and another interfaces like below:
  18. #compute01 neutron_external_interface=eth0 api_interface=em1 storage_interface=em1 tunnel_interface=em1
  19. [storage]
  20. storage01
  21. [baremetal:children]
  22. control
  23. network
  24. compute
  25. storage
  26. # You can explicitly specify which hosts run each project by updating the
  27. # groups in the sections below. Common services are grouped together.
  28. [kibana:children]
  29. control
  30. [elasticsearch:children]
  31. control
  32. [haproxy:children]
  33. network
  34. [mariadb:children]
  35. control
  36. [rabbitmq:children]
  37. control
  38. [mongodb:children]
  39. control
  40. [keystone:children]
  41. control
  42. [glance:children]
  43. control
  44. [nova:children]
  45. control
  46. [neutron:children]
  47. network
  48. [cinder:children]
  49. control
  50. [memcached:children]
  51. control
  52. [horizon:children]
  53. control
  54. [swift:children]
  55. control
  56. [heat:children]
  57. control
  58. [murano:children]
  59. control
  60. [ironic:children]
  61. control
  62. [ceph-mon:children]
  63. control
  64. [ceph-rgw:children]
  65. control
  66. [ceph-osd:children]
  67. storage
  68. # Additional control implemented here. These groups allow you to control which
  69. # services run on which hosts at a per-service level.
  70. #
  71. # Word of caution: Some services are required to run on the same host to
  72. # function appropriately. For example, neutron-metadata-agent must run on the
  73. # same host as the l3-agent and (depending on configuration) the dhcp-agent.
  74. # Glance
  75. [glance-api:children]
  76. glance
  77. [glance-registry:children]
  78. glance
  79. # Nova
  80. [nova-api:children]
  81. nova
  82. [nova-conductor:children]
  83. nova
  84. [nova-consoleauth:children]
  85. nova
  86. [nova-novncproxy:children]
  87. nova
  88. [nova-scheduler:children]
  89. nova
  90. [nova-spicehtml5proxy:children]
  91. nova
  92. [nova-compute-ironic:children]
  93. nova
  94. # Neutron
  95. [neutron-server:children]
  96. control
  97. [neutron-dhcp-agent:children]
  98. neutron
  99. [neutron-l3-agent:children]
  100. neutron
  101. [neutron-lbaas-agent:children]
  102. neutron
  103. [neutron-metadata-agent:children]
  104. neutron

默认我们会把haproxy放到network节点,如果我想把haproxy放到一个单独的节点,那么我只需要到这样修改

  1. -[haproxy:children]
  2. -network
  3. +[haproxy]
  4. +haproxy01
  5. +haproxy02

配置文件管理

每个openstack服务都运行在一个容器中,那kolla是怎么管理openstack的配置的呢? 我们拿nova-compute的配置管理来举例

首先kolla会使用ansible为nova-compute生成一份配置文件放在/etc/kolla/nova-compute/目录下。

  1. #nova_custom_config默认是/etc/kolla/configs/nova
  2. #node_config_directory默认是 /etc/kolla
  3. - name: Copying over nova.conf
  4. merge_configs:
  5. vars:
  6. service_name: "{{ item }}"
  7. sources:
  8. - "{{ role_path }}/templates/nova.conf.j2"
  9. - "{{ node_custom_config }}/global.conf"
  10. - "{{ node_custom_config }}/database.conf"
  11. - "{{ node_custom_config }}/messaging.conf"
  12. - "{{ node_custom_config }}/nova.conf"
  13. - "{{ node_custom_config }}/nova/{{ item }}.conf"
  14. - "{{ node_custom_config }}/nova/{{ inventory_hostname }}/nova.conf"
  15. dest: "{{ node_config_directory }}/{{ item }}/nova.conf"
  16. with_items:
  17. - "nova-api"
  18. - "nova-compute"
  19. - "nova-compute-ironic"
  20. - "nova-conductor"
  21. - "nova-consoleauth"
  22. - "nova-novncproxy"
  23. - "nova-scheduler"
  24. - "nova-spicehtml5proxy"

大家可能会注意到kolla使用merge_configs来完成配置文件的合并,那么merge_configs是干什么的呢?顾名思义,merge_configs就是把多个配置文件合成一个,kolla为什么要这样做呢?
openstack配置选项非常多但是真正需要管理的则很少,对这部分选项kolla使用模版的方式管理,同时由于merge_configs的使用,使得用户可以非常方便的添加自己的定制化选项。比如你部署kolla在一台虚拟机上,你必须使用QEMU hypervisor来替代KVM hypervisor。那么你可以在/etc/kolla/config/nova/nova-compute.conf中添加以下配置

  1. [libvirt]
  2. virt_type=qemu

merge_configs的代码在 ansible/action_plugins/merge_configs.py

启动容器时/etc/kolla以docker卷的形式挂载到/var/lib/kolla/config_files目录下

  1. - name: Starting nova-libvirt container
  2. kolla_docker:
  3. action: "start_container"
  4. common_options: "{{ docker_common_options }}"
  5. image: "{{ nova_libvirt_image_full }}"
  6. name: "nova_libvirt"
  7. pid_mode: "host"
  8. privileged: True
  9. volumes:
  10. - "{{ node_config_directory }}/nova-libvirt/:{{ container_config_directory }}/:ro"
  11. - "/etc/localtime:/etc/localtime:ro"
  12. - "/lib/modules:/lib/modules:ro"
  13. - "/run/:/run/"
  14. - "/dev:/dev"
  15. - "/sys/fs/cgroup:/sys/fs/cgroup"
  16. - "kolla_logs:/var/log/kolla/"
  17. - "libvirtd:/var/lib/libvirt"
  18. - "nova_compute:/var/lib/nova/"
  19. - "nova_libvirt_qemu:/etc/libvirt/qemu"
  20. when: inventory_hostname in groups['compute']

容器启动脚本会根据nova-compute.json来将配置文件拷贝到/etc并设置合适的权限

  1. {
  2. "command": "nova-compute",
  3. "config_files": [
  4. {
  5. "source": "{{ container_config_directory }}/nova.conf",
  6. "dest": "/etc/nova/nova.conf",
  7. "owner": "nova",
  8. "perm": "0600"
  9. }{% if nova_backend == "rbd" %},
  10. {
  11. "source": "{{ container_config_directory }}/ceph.*",
  12. "dest": "/etc/ceph/",
  13. "owner": "nova",
  14. "perm": "0700"
  15. }{% endif %}
  16. ]
  17. }

关于kolla配置文件的管理还可以参考这里

nova-fake测试控制平台性能

这里

compute节点升级问题

由于所有服务都运行在容器中,那么是不是我升级compute节点时,该节点的虚机都会进入关机状态呢,kolla使用super-privilege的容器来解决了这个问题具体可以参考kolla PTL的文章https://sdake.io/2015/01/28/an-atomic-upgrade-process-for-openstack-compute-nodes/

平滑升级

kolla为升级也编写了upgrade.yaml这个playbook,我们还是拿nova-compute的升级为例

  1. # kolla/ansible/roles/nova/tasks/upgrade.yml
  2. ---
  3. # Create new set of configs on nodes
  4. - include: config.yml
  5. # TODO(inc0): since nova is creating new database in L->M, we need to call it.
  6. # It should be removed later
  7. - include: bootstrap.yml
  8. - include: bootstrap_service.yml
  9. - name: Checking if conductor container needs upgrading
  10. kolla_docker:
  11. action: "compare_image"
  12. common_options: "{{ docker_common_options }}"
  13. name: "nova_conductor"
  14. image: "{{ nova_conductor_image_full }}"
  15. when: inventory_hostname in groups['nova-conductor']
  16. register: conductor_differs
  17. # Short downtime here, but from user perspective his call will just timeout or execute later
  18. - name: Stopping all nova_conductor containers
  19. kolla_docker:
  20. action: "stop_container"
  21. common_options: "{{ docker_common_options }}"
  22. name: "nova_conductor"
  23. when:
  24. - inventory_hostname in groups['nova-conductor']
  25. - conductor_differs['result']
  26. - include: start_conductors.yml
  27. - include: start_controllers.yml
  28. serial: "30%"
  29. - include: start_compute.yml
  30. serial: "10%"
  31. - include: reload.yml
  32. serial: "30%"

使用


查看log

  1. cd /var/lib/docker/volumes/kolla_logs/

进入容器调试

  1. docker exec -it service_name bash

root权限问题

出于安全考虑很多kolla服务都是运行在非root下,进入容器后拿不到root权限,我们还以nova_compute为例,可以修改/etc/kolla/nova_compute/config.json改为以下

  1. {
  2. "command": "nova-compute",
  3. "config_files": [
  4. {
  5. "source": "/var/lib/kolla/config_files/nova.conf",
  6. "dest": "/etc/nova/nova.conf",
  7. "owner": "nova",
  8. "perm": "0600"
  9. },
  10. {
  11. "source": "/var/lib/kolla/config_files/nova.sudo",
  12. "dest": "/etc/sudoers.d/nova.sudo",
  13. "owner": "root",
  14. } ]
  15. }

然后在/etc/kolla/nova-compute添加nova.sudo

  1. nova ALL=(ALL) NOPASSWD: ALL

重启容器后即可sudo到root用户下调试

定制化build镜像

参考 https://github.com/openstack/kolla/blob/master/doc/image-building.rst

总结


优点

  • 配置管理灵活方便
  • 可以平滑升级
  • 部署简单
  • 环境隔离
  • 多种安装源
  • 支持的部署的服务多

缺点

  • 对新手的友好程度
  • debug不方便