鉴于lxc容器特别像虚拟机的特点,rackspace,都有把openstack部署到lxc容器里的实践,恰好lxc也有类似教程,打算自己跑一遍,看看是怎样一种体验
how to run a full OpenStack, using LXD containers instead of VMs and running all of this inside a LXD container (nesting!).
安装lxd
还是ubuntu好,直接apt就行了,不像在centos上,需要从头开始编译liblxc,lxd试验记录。更可怕的是,AppArmor/SeLinux/Seccomp/user namespace/都需要另外安装,如果不安装,就需要在编译liblxc时disable掉
1 | sudo apt-get update |
安装完成后,查看版本1
2
3
4i3@i3:~$ lxc --version
2.0.8
i3@i3:~$ lxd --version
2.0.8
安装ZFS
Feature | Directory | Btrfs | LVM | ZFS |
---|---|---|---|---|
Optimized image storage | no | yes | yes | yes |
Optimized container creation | no | yes | yes | yes |
Optimized snapshot creation | no | yes | yes | yes |
Optimized image transfer | no | yes | no | yes |
Optimized container transfer | no | yes | no | yes |
Copy on write | no | yes | yes | yes |
Block based | no | no | yes | no |
Instant cloning | no | yes | yes | yes |
Nesting support | yes | yes | no | no |
Restore from older snapshots (not latest) | yes | yes | yes | no |
Storage quotas | no | yes | no | yes |
lxc支持的存储后端,看来ZFS不错,打算用他
1 | sudo apt-add-repository ppa:zfs-native/stable |
init lxd
1 | sudo lxd init |
需要注意:如果是想在嵌套容器里跑openstack,那么网络只选择IPV4和存储后端用DIR
完成后1
2$brctl show
lxdbr0 8000.000000000000 no
多了一个linux桥
启动容器
1 | sudo lxc launch ubuntu:16.04 first |
resource control
https://stgraber.org/2016/03/26/lxd-2-0-resource-control-412/
cpu
1 | i3@i3:~$ sudo lxc config set first limits.cpu 1 |
内存
1 | root@first:~# cat /proc/meminfo |
openstack
容器已经成功创建,开始尝试openstack
1 | sudo lxc init ubuntu:16.04 openstack -c security.privileged=true -c security.nesting=true -c "linux.kernel_modules=iptable_nat, ip6table_nat, ebtables, openvswitch, nbd" |
可以看到openstack容器已经运行
1 | i3@i3:~$ sudo lxc list |
安装juju
1 | sudo lxc exec openstack -- apt update |
初始化容器里的lxd1
sudo lxc exec openstack -- lxd init
参考
https://stgraber.org/2016/10/26/lxd-2-0-lxd-and-openstack-1112/
https://stgraber.org/2016/03/15/lxd-2-0-installing-and-configuring-lxd-212/
本博客欢迎转发,但请保留原作者信息
github:codejuan
博客地址:http://blog.decbug.com/