OpenStack Liberty部署Nova-Docker

一 OpenStack安装
参考https://www.rdoproject.org//,使用packstack安装all-in-one OpenStack。OS:centos7

二 安装nova-docker插件

  git clone https://github.com/openstack/nova-docker.git
  git checkout  stable/liberty

注意:clone完代码后,需要切换分之到stable/liberty!!!

安装nova-docker

python setup.py install

安装docker&docker-py

yum install -y docker
pip install docker-py

配置nova

compute_driver=novadocker.virt.docker.driver.DockerDriver

配置glance

container_formats=ami,ari,aki,bare,ovf,ova,docker

添加docker group,并将nova加入docker group。否则,nova无权限和docker交互。

groupadd docker
sudo usermod -aG docker nova

关闭selinux,否则在启动容器时无法绑定port,/etc/selinux/config

SELINUX=disabled

重启启动机器,查询hypervisor信息

[root@localhost nova-docker(keystone_admin)]# nova hypervisor-list
+----+-----------------------+-------+---------+
| ID | Hypervisor hostname   | State | Status  |
+----+-----------------------+-------+---------+
| 1  | localhost.localdomain | up    | enabled |
+----+-----------------------+-------+---------+
[root@localhost nova-docker(keystone_admin)]# 
[root@localhost nova-docker(keystone_admin)]# nova hypervisor-show 1
+-------------------------+-----------------------+
| Property                | Value                 |
+-------------------------+-----------------------+
| cpu_info                | ?                     |
| current_workload        | 0                     |
| disk_available_least    | 32                    |
| free_disk_gb            | 37                    |
| free_ram_mb             | 10259                 |
| host_ip                 | 192.168.2.67          |
| hypervisor_hostname     | localhost.localdomain |
| hypervisor_type         | docker                |
| hypervisor_version      | 1000                  |
| id                      | 1                     |
| local_gb                | 38                    |
| local_gb_used           | 1                     |
| memory_mb               | 11283                 |
| memory_mb_used          | 1024                  |
| running_vms             | 1                     |
| service_disabled_reason | None                  |
| service_host            | localhost.localdomain |
| service_id              | 4                     |
| state                   | up                    |
| status                  | enabled               |
| vcpus                   | 8                     |
| vcpus_used              | 1                     |
+-------------------------+-----------------------+

综上,可以看出当前节点的hypervisor已经变成了docker且当前阶段时up状态。

三 创建docker容器
上传镜像

docker pull busybox
docker save busybox | openstack image create busybox --public --container-format docker --disk-format raw
glance image-update --property os_command_line='/usr/sbin/sshd -D' $IMAGE_ID

创建容器

nova boot --flavor m1.small --image busybox --key-name mykey test1

查看结果

[root@localhost nova-docker(keystone_admin)]# nova list
+--------------------------------------+---------+--------+------------+-------------+-------------------+
| ID                                   | Name    | Status | Task State | Power State | Networks          |
+--------------------------------------+---------+--------+------------+-------------+-------------------+
| ab130ab4-1e3b-4e0e-a6bf-714f69308ac8 | busybox | ACTIVE | -          | Running     | You=192.168.2.207 |
+--------------------------------------+---------+--------+------------+-------------+-------------------+
[root@localhost nova-docker(keystone_admin)]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
a1670ce4d91b        busybox             "sleep 300"         6 seconds ago       Up 5 seconds                            nova-ab130ab4-1e3b-4e0e-a6bf-714f69308ac8
[root@localhost nova-docker(keystone_admin)]# 

值得,注意的是当前的nova-docker driver插件并不是非常的完善。如果要应用的生产环境,还需要做一些质量的加固。

你可能感兴趣的:(OpenStack Liberty部署Nova-Docker)