关闭

使用Juju将OpenStack部署在单机的LXD容器上(by quqi99)

标签: lxdopenstackjuju
1524人阅读 评论(0) 收藏 举报
分类:

**作者:张华 发表于:2016-08-05
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
http://blog.csdn.net/quqi99 )**

理论基础

  1. iscsi还不能运行在容器里(因为netlink还不支持namesapce),本文采用rbd使用ceph代替iscsi
  2. ovs, kvm通过定义profile支持运行在容器里。ovs目前只支持security.privileged: “true”

配置LXD

参考Play with LXD一文 在ubuntu 16.04上部署LXD环境。略。然后继续执行:

**lxc profile create juju-default** 2>/dev/null || echo "juju-default profile already exists"
wget https://api.jujucharms.com/charmstore/v5/~james-page/openstack-on-lxd/archive
unzip openstack-on-lxd.zip
modprobe nbd
cat lxd-profile.yaml | lxc profile edit juju-default
$ cat lxd-profile.yaml 
name: juju-default
config:
  boot.autostart: "true"
  security.nesting: "true"
  security.privileged: "true"
  linux.kernel_modules: openvswitch,nbd,ip_tables,ip6_tables
devices:
  eth0:
    mtu: "9000"
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  eth1:
    mtu: "9000"
    name: eth1
    nictype: bridged
    parent: lxdbr0
    type: nic
  kvm:
    path: /dev/kvm
    type: unix-char
  mem:
    path: /dev/mem
    type: unix-char
  root:
    path: /
    type: disk
  tun:
    path: /dev/net/tun
    type: unix-char

使用Juju在单机上部署OpenStack

**juju bootstrap --config config.yaml localhost lxd**
lxc exec `lxc list |grep juju- |awk -F '|' '{print $2}'` bash
$ cat config.yaml 
default-series: xenial
agent-stream: devel
#apt-http-proxy: http://10.0.8.1:8000

juju deploy bundle.yaml
juju status
juju debug-log
$ cat bundle.yaml 
relations:
- - nova-compute:amqp
  - rabbitmq-server:amqp
- - neutron-gateway:amqp
  - rabbitmq-server:amqp
- - keystone:shared-db
  - mysql:shared-db
- - nova-cloud-controller:identity-service
  - keystone:identity-service
- - glance:identity-service
  - keystone:identity-service
- - neutron-api:identity-service
  - keystone:identity-service
- - neutron-openvswitch:neutron-plugin-api
  - neutron-api:neutron-plugin-api
- - neutron-api:shared-db
  - mysql:shared-db
- - neutron-api:amqp
  - rabbitmq-server:amqp
- - neutron-gateway:neutron-plugin-api
  - neutron-api:neutron-plugin-api
- - glance:shared-db
  - mysql:shared-db
- - glance:amqp
  - rabbitmq-server:amqp
- - nova-cloud-controller:image-service
  - glance:image-service
- - nova-compute:image-service
  - glance:image-service
- - nova-cloud-controller:cloud-compute
  - nova-compute:cloud-compute
- - nova-cloud-controller:amqp
  - rabbitmq-server:amqp
- - nova-cloud-controller:quantum-network-service
  - neutron-gateway:quantum-network-service
- - nova-compute:neutron-plugin
  - neutron-openvswitch:neutron-plugin
- - neutron-openvswitch:amqp
  - rabbitmq-server:amqp
- - openstack-dashboard:identity-service
  - keystone:identity-service
- - nova-cloud-controller:shared-db
  - mysql:shared-db
- - nova-cloud-controller:neutron-api
  - neutron-api:neutron-api
- - cinder:image-service
  - glance:image-service
- - cinder:amqp
  - rabbitmq-server:amqp
- - cinder:identity-service
  - keystone:identity-service
- - cinder:cinder-volume-service
  - nova-cloud-controller:cinder-volume-service
- - cinder-ceph:storage-backend
  - cinder:storage-backend
- - ceph:client
  - nova-compute:ceph
- - cinder:shared-db
  - mysql:shared-db
- - ceph:client
  - cinder-ceph:ceph
- - ceph:client
  - glance:ceph
- - ceph-radosgw:mon
  - ceph:radosgw
- - ceph-radosgw:identity-service
  - keystone:identity-service
series: xenial
services:
  ceph:
    annotations:
      gui-x: '750'
      gui-y: '500'
    charm: cs:xenial/ceph
    num_units: 3
    options:
      fsid: 5a791d94-980b-11e4-b6f6-3c970e8b1cf7
      monitor-secret: AQAi5a9UeJXUExAA+By9u+GPhl8/XiUQ4nwI3A==
      osd-devices: /srv/osd
      use-direct-io: False
  ceph-radosgw:
    annotations:
      gui-x: '1000'
      gui-y: '250'
    charm: cs:xenial/ceph-radosgw
    num_units: 1
    options:
      use-embedded-webserver: true
  cinder:
    annotations:
      gui-x: '750'
      gui-y: '0'
    charm: cs:xenial/cinder
    num_units: 1
    options:
      block-device: None
      glance-api-version: 2
  cinder-ceph:
    annotations:
      gui-x: '750'
      gui-y: '250'
    charm: cs:xenial/cinder-ceph
    num_units: 0
  glance:
    annotations:
      gui-x: '250'
      gui-y: '0'
    charm: cs:xenial/glance
    num_units: 1
  keystone:
    annotations:
      gui-x: '500'
      gui-y: '0'
    charm: cs:xenial/keystone
    num_units: 1
    options:
      admin-password: openstack
  mysql:
    annotations:
      gui-x: '0'
      gui-y: '250'
    charm: cs:xenial/percona-cluster
    num_units: 1
    options:
      max-connections: 20000
      dataset-size: 256M
  neutron-api:
    annotations:
      gui-x: '500'
      gui-y: '500'
    charm: cs:xenial/neutron-api
    num_units: 1
    options:
      neutron-security-groups: true
      overlay-network-type: "gre vxlan"
  neutron-gateway:
    annotations:
      gui-x: '0'
      gui-y: '0'
    charm: cs:xenial/neutron-gateway
    num_units: 1
    options:
      ext-port: eth1
  neutron-openvswitch:
    annotations:
      gui-x: '250'
      gui-y: '500'
    charm: cs:xenial/neutron-openvswitch
    num_units: 0
  nova-cloud-controller:
    annotations:
      gui-x: '0'
      gui-y: '500'
    charm: cs:xenial/nova-cloud-controller
    num_units: 1
    options:
      network-manager: Neutron
  nova-compute:
    annotations:
      gui-x: '250'
      gui-y: '250'
    charm: cs:xenial/nova-compute
    num_units: 1
    options:
      enable-live-migration: False
      enable-resize: False
      migration-auth-type: ssh
  openstack-dashboard:
    annotations:
      gui-x: '500'
      gui-y: '-250'
    charm: cs:xenial/openstack-dashboard
    num_units: 1
  rabbitmq-server:
    annotations:
      gui-x: '500'
      gui-y: '250'
    charm: cs:xenial/rabbitmq-server
    num_units: 1

配置使用OpenStack

source novarc
$ cat novarc 
#!/bin/bash
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_TENANT_NAME=admin
export OS_REGION_NAME=RegionOne
export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://`juju run --unit  keystone/0 "unit-get private-address"`:5000/v2.0

curl http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
openstack image create --public --container-format=bare --disk-format=qcow2 xenial

./neutron-ext-net -g 10.0.8.1 -c 10.0.8.0/24 \ -f 10.0.8.201:10.0.8.254 ext_net
./neutron-tenant-net -t admin -r provider-router \ -N 10.0.8.1 internal 192.168.20.0/24

nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
nova boot --image xenial --flavor m1.small --key-name mykey --nic net-id=$(neutron net-list | grep internal | awk '{ print $2 }') i1

cinder create --name testvolume 10
nova volume-attach xenial $(cinder list | grep testvolume | awk '{ print $2 }') /dev/vdc

nova floating-ip-create 
nova add-floating-ip <uuid-of-instance> <new-floating-ip>

neutron security-group-rule-create --protocol icmp --direction ingress $(nova secgroup-list | grep default | awk '{ print $2 }') 
neutron security-group-rule-create --protocol tcp  --port-range-min 22 --port-range-max 22  --direction ingress $(nova secgroup-list | grep default | awk '{ print $2 }')

ssh ubuntu@<new-floating-ip>

又一例 - 部署opencontrail在lxd单机上

下面的yaml是juju2.0的,如果是juju1.x可见:http://pastebin.ubuntu.com/24170320/
实际上,opencontrail vrouter部署在容器里会报下列错,此例子只是说明yaml怎么写。

2017-03-13 11:46:06 INFO juju-log Loading kernel module vrouter
2017-03-13 11:46:06 INFO install modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.8.0-34-generic/modules.dep.bin'
2017-03-13 11:46:06 INFO juju-log vrouter kernel module failed to load, clearing pagecache and retrying
series: trusty
services:
  # openstack
  ubuntu:
    charm: cs:trusty/ubuntu
    num_units: 1
  ntp:
    charm: cs:trusty/ntp
  mysql:
    charm: cs:trusty/mysql
    options:
      dataset-size: 15%
      max-connections: 1000
    num_units: 1
  rabbitmq-server:
    charm: cs:trusty/rabbitmq-server
    num_units: 1
  keystone:
    charm: cs:~sdn-charmers/trusty/keystone
    options:
      admin-password: password
      admin-role: admin
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  nova-cloud-controller:
    charm: cs:trusty/nova-cloud-controller
    options:
      network-manager: Neutron
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  neutron-api:
    charm: cs:trusty/neutron-api
    options:
      manage-neutron-plugin-legacy-mode: false
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  glance:
    charm: cs:trusty/glance
    options:
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  openstack-dashboard:
    charm: cs:trusty/openstack-dashboard
    options:
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  nova-compute:
    charm: cs:trusty/nova-compute
    options:
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  # contrail
  cassandra:
    charm: cs:trusty/cassandra
    options:
      authenticator: AllowAllAuthenticator
      install_sources: |
        - deb http://www.apache.org/dist/cassandra/debian 22x main
        - ppa:openjdk-r/ppa
        - ppa:stub/cassandra
    num_units: 1
  zookeeper:
    charm: cs:~charmers/trusty/zookeeper
    num_units: 1
  kafka:
    charm: cs:~sdn-charmers/trusty/apache-kafka
    num_units: 1
  contrail-configuration:
    charm: cs:~sdn-charmers/trusty/contrail-configuration
    options:
      openstack-origin: cloud:trusty-mitaka
    num_units: 1
  contrail-control:
    charm: cs:~sdn-charmers/trusty/contrail-control
    num_units: 1
  contrail-analytics:
    charm: cs:~sdn-charmers/trusty/contrail-analytics
    num_units: 1
  contrail-webui:
    charm: cs:~sdn-charmers/trusty/contrail-webui
    num_units: 1
  neutron-api-contrail:
    charm: cs:~sdn-charmers/trusty/neutron-api-contrail
    num_units: 0
  neutron-contrail:
    charm: cs:~sdn-charmers/trusty/neutron-contrail
    num_units: 0

relations:
  # openstack
  - [ ubuntu, ntp ]
  - [ keystone, mysql ]
  - [ glance, mysql ]
  - [ glance, keystone ]
  - [ nova-cloud-controller, mysql ]
  - [ nova-cloud-controller, rabbitmq-server ]
  - [ nova-cloud-controller, keystone ]
  - [ nova-cloud-controller, glance ]
  - [ neutron-api, mysql ]
  - [ neutron-api, rabbitmq-server ]
  - [ neutron-api, nova-cloud-controller ]
  - [ neutron-api, keystone ]
  - [ neutron-api, neutron-api-contrail ]
  - [ "nova-compute:shared-db", "mysql:shared-db" ]
  - [ "nova-compute:amqp", "rabbitmq-server:amqp" ]
  - [ nova-compute, glance ]
  - [ nova-compute, nova-cloud-controller ]
  - [ nova-compute, ntp ]
  - [ openstack-dashboard, keystone ]
  # contrail
  - [ kafka, zookeeper ]
  - [ "contrail-configuration:cassandra", "cassandra:database" ]
  - [ contrail-configuration, zookeeper ]
  - [ contrail-configuration, rabbitmq-server ]
  - [ "contrail-configuration:identity-admin", "keystone:identity-admin" ]
  - [ "contrail-configuration:identity-service", "keystone:identity-service" ]
  - [ neutron-api-contrail, contrail-configuration ]
  - [ neutron-api-contrail, keystone ]
  - [ "contrail-control:contrail-api", "contrail-configuration:contrail-api" ]
  - [ "contrail-control:contrail-discovery", "contrail-configuration:contrail-discovery" ]
  - [ "contrail-control:contrail-ifmap", "contrail-configuration:contrail-ifmap" ]
  - [ contrail-control, keystone ]
  - [ "contrail-analytics:cassandra", "cassandra:database" ]
  - [ contrail-analytics, kafka ]
  - [ contrail-analytics, zookeeper ]
  - [ "contrail-analytics:contrail-api", "contrail-configuration:contrail-api" ]
  - [ "contrail-analytics:contrail-discovery", "contrail-configuration:contrail-discovery" ]
  - [ "contrail-analytics:identity-admin", "keystone:identity-admin" ]
  - [ "contrail-analytics:identity-service", "keystone:identity-service" ]
  - [ "contrail-configuration:contrail-analytics-api", "contrail-analytics:contrail-analytics-api" ]
  - [ nova-compute, neutron-contrail ]
  - [ "neutron-contrail:contrail-discovery", "contrail-configuration:contrail-discovery" ]
  - [ "neutron-contrail:contrail-api", "contrail-configuration:contrail-api" ]
  - [ neutron-contrail, keystone ]
  - [ contrail-webui, keystone ]
  - [ "contrail-webui:cassandra", "cassandra:database" ]

参考

0
0

猜你在找
深度学习基础与TensorFlow实践
【在线峰会】前端开发重点难点技术剖析与创新实践
【在线峰会】一天掌握物联网全栈开发之道
【在线峰会】如何高质高效的进行Android技术开发
机器学习40天精英计划
Python数据挖掘与分析速成班
微信小程序开发实战
JFinal极速开发企业实战
备战2017软考 系统集成项目管理工程师 学习套餐
Python大型网络爬虫项目开发实战(全套)
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1352793次
    • 积分:15415
    • 等级:
    • 排名:第661名
    • 原创:290篇
    • 转载:10篇
    • 译文:0篇
    • 评论:298条