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

标签: lxdopenstackjuju
1955人阅读 评论(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"
# Download openstack-on-lxd from 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 --debug --config bootstrap-series=xenial --config agent-stream=devel localhost juju-default
lxc exec `lxc list |grep juju- |awk -F '|' '{print $2}'` bash
juju deploy bundle.yaml
juju status
juju debug-log
$ cat bundle.yaml 
debug:                      &debug                     True
verbose:                    &verbose                   True
series: xenial
services:
  rabbitmq-server:
    num_units: 1
    charm: cs:~openstack-charmers-next/rabbitmq-server
    constraints: mem=1G
    options:
      source: cloud:xenial-mitaka
  keystone:
    num_units: 1
    charm: cs:~openstack-charmers-next/keystone
    constraints: mem=1G
    options:
      debug: *debug
      verbose: *verbose
      admin-password: openstack
      admin-token: ubuntutesting
      openstack-origin: cloud:xenial-mitaka
  openstack-dashboard:
    num_units: 1
    charm: cs:~openstack-charmers-next/openstack-dashboard
    constraints: mem=1G
    options:
      openstack-origin: cloud:xenial-mitaka
  nova-compute:
    charm: cs:~openstack-charmers-next/nova-compute
    num_units: 3
    constraints: mem=4G
    options:
      debug: *debug
      verbose: *verbose
      enable-live-migration: True
      enable-resize: True
      migration-auth-type: ssh
      openstack-origin: cloud:xenial-mitaka
  nova-cloud-controller:
    num_units: 1
    charm: cs:~openstack-charmers-next/nova-cloud-controller
    constraints: mem=1G
    options:
      debug: *debug
      verbose: *verbose
      network-manager: Neutron
      openstack-origin: cloud:xenial-mitaka
  neutron-gateway:
    num_units: 1
    charm: cs:~openstack-charmers-next/neutron-gateway
    constraints: mem=4G
    options:
      debug: *debug
      verbose: *verbose
      instance-mtu: 1300
      bridge-mappings: physnet1:br-ex
      openstack-origin: cloud:xenial-mitaka
  neutron-api:
    num_units: 1
    charm: cs:~openstack-charmers-next/neutron-api
    constraints: mem=1G
    options:
      debug: *debug
      verbose: *verbose
      neutron-security-groups: True
      flat-network-providers: physnet1
      openstack-origin: cloud:xenial-mitaka
  neutron-openvswitch:
    charm: cs:~openstack-charmers-next/neutron-openvswitch
  cinder:
    num_units: 1
    charm: cs:~openstack-charmers-next/cinder
    options:
      debug: *debug
      verbose: *verbose
      block-device: /dev/vdb
      ephemeral-unmount: "/mnt"
      overwrite: "true"
      glance-api-version: 2
      openstack-origin: cloud:xenial-mitaka
    constraints: mem=1G
  glance:
    num_units: 1
    charm: cs:~openstack-charmers-next/glance
    constraints: mem=1G
    options:
      debug: *debug
      verbose: *verbose
      openstack-origin: cloud:xenial-mitaka
  mysql:
    num_units: 1
    charm: cs:~openstack-charmers-next/percona-cluster
    constraints: mem=4G
    options:
      dataset-size: 50%
      max-connections: 20000
      root-password: ChangeMe123
      sst-password: ChangeMe123
      source: cloud:xenial-mitaka
relations:
  - [ keystone, mysql ]
  - [ nova-cloud-controller, mysql ]
  - [ nova-cloud-controller, rabbitmq-server ]
  - [ nova-cloud-controller, glance ]
  - [ nova-cloud-controller, keystone ]
  - [ nova-compute, nova-cloud-controller ]
  - [ nova-compute, mysql ]
  - - nova-compute
    - rabbitmq-server:amqp
  - [ nova-compute, glance ]
  - [ glance, mysql ]
  - [ glance, keystone ]
  - [ glance, "cinder:image-service" ]
  - [ glance, rabbitmq-server ]
  - [ cinder, mysql ]
  - [ cinder, rabbitmq-server ]
  - [ cinder, nova-cloud-controller ]
  - [ cinder, keystone ]
  - [ neutron-gateway, nova-cloud-controller ]
  - [ openstack-dashboard, keystone ]
  - [ "neutron-gateway:amqp", rabbitmq-server ]
  - [ neutron-api, mysql ]
  - [ neutron-api, rabbitmq-server ]
  - [ neutron-api, nova-cloud-controller ]
  - [ neutron-api, neutron-openvswitch ]
  - [ neutron-api, keystone ]
  - [ neutron-api, neutron-gateway ]
  - [ neutron-openvswitch, nova-compute ]
  - [ neutron-openvswitch, rabbitmq-server ]

配置使用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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1407455次
    • 积分:16298
    • 等级:
    • 排名:第659名
    • 原创:300篇
    • 转载:10篇
    • 译文:0篇
    • 评论:299条