Openstack容器项目之Magnum
1.Magnum简介
Magnum项目通过Openstack API能够在Openstack中创建基于容器的服务,但它本身并不直接对容器进行操作,而是通过Kubernetes, Swarm或者Mesos后端进行管理。Openstack正式项目Zun具有直接管理docker的功能。
Magnum特征:
(1)Clusters(node对象的集合, 以前版本称为Bay)抽象化。
(2)与Kubernetes, Swarm以及Mesos进行集成,管理容器。
(3)与Keystone集成,提供多租户安全。
(4)与Neutron集成,为Kubernetes提供多租户安全。
(5)与Cinder集成,为容器提供volume服务。

3.Magnum命令
command | parameters | function | example |
cluster-create |
--cluster-template \ The ID or name of the ClusterTemplate to use. --name \ Name of the cluster to create. --keypair \ The name or UUID of the SSH keypair to configure in the cluster servers for ssh access. --node-count \ The number of servers that will serve as node in the cluster. --master-count \ The number of servers that will serve as master for the cluster. --discovery-url \ The custom discovery url for node discovery. --timeout \ The timeout for cluster creation in minutes. |
创建一个cluster,以异步的方式执行。 |
magnum cluster-create --name mycluster \ --cluster-template mytemplate \ --node-count 8 \ --master-count 3 说明:使用名为mytemplate的模板, 创建了一个拥有8个node, 3个master node, 名为mycluster的cluster |
cluster-delete | 通过name或ID删除一个cluster | magnum cluster-delete mycluster | |
cluster-list | 列出所以得cluster | magnum cluster-list | |
cluster-show | 显示某个cluster的详细信息 | magnum cluster-show mycluster | |
cluster-update |
<cluster> \ This is the first parameter, specifying the UUID or name of the cluster to update. <op> \ This is the second parameter, specifying the desired change to be made to the cluster attributes. The allowed changes are 'add', 'replace' and 'remove'. <attribute=value> \ This is the third parameter, specifying the targeted attributes in the cluster as a list separated by blank space. |
更新某个cluster |
magnum cluster-update mycluster replace node_count=8 说明:把mycluster中的node节点设置为8 |
cluster-template-create |
--coe \ Specify the Container Orchestration Engine to use. Supported COE's include 'kubernetes', 'swarm', 'mesos'. --image \ The name or UUID of the base image in Glance to boot the servers for the cluster. --keypair \ The name or UUID of the SSH keypair to configure in the cluster servers for ssh access. --external-network \ The name or network ID of a Neutron network to provide connectivity to the external internet for the cluster. --name \ Name of the ClusterTemplate to create. --public \ Access to a ClusterTemplate is normally limited to the admin, owner or users within the same tenant as the owners. --server-type \ The servers in the cluster can be VM or baremetal. --volume-driver \ The name of a volume driver for managing the persistent storage for the containers. --dns-nameserver \ The DNS nameserver for the servers and containers in the cluster to use. --flavor \ The nova flavor id for booting the node servers. --master-flavor \ The nova flavor id for booting the master or manager servers. --http-proxy /--https-proxy \ The IP address for a proxy to use when direct http/https access from the servers to sites on the external internet is blocked. --no-proxy \ When a proxy server is used, some sites should not go through the proxy and should be accessed normally. --docker-volume-size \ If specified, container images will be stored in a cinder volume of the specified size in GB. --docker-storage-driver \ The name of a driver to manage the storage for the images and the container's writable layer. --labels \ Arbitrary labels in the form of key=value pairs. --tls-disabled \ Transport Layer Security (TLS) is normally enabled to secure the cluster. --registry-enabled \ Docker images by default are pulled from the public Docker registry, but in some cases, users may want to use a private registry. --master-lb-enabled \ Since multiple masters may exist in a bay, a load balancer is created to provide the API endpoint for the bay and to direct requests to the masters. |
创建cluster template |
magnum cluster-template-create --name mesos-cluster-template \ --image ubuntu-mesos \ --keypair testkey \ --external-network public \ --dns-nameserver 8.8.8.8 \ --master-flavor m1.magnum \ --docker-volume-size 4 \ --tls-disabled \ --flavor m1.magnum \ --coe mesos \ --volume-driver rexray \ --labels rexray-preempt=true |
cluster-template-delete | 删除某个模板 | magnum cluster-template-delete mytemplate | |
cluster-template-list | 列出所有的模板 | magnum cluster-template-delete | |
cluster-template-show | 显示某个模板的详细信息 | magnum cluster-template-show mytemplate | |
cluster-template-update | 更新某个模板 | magnum cluster-template-update mytemplate [ ...] | |
service-list | 列出所以得magnum service | magnum service-list | |
ca-show | 显示某个cluster CA certificate 的详细信息 | magnum ca-show mycluster | |
ca-sign |
--csr File path of the csr file to send to Magnum to get signed. --cluster ID or name of the cluster. |
为某个cluster产生一个CA certificate | |
cluster-config | Configure native client to access cluster. | ||
stats-list | Show stats for the given project_id | magnum stats-list [--project-id ] |
说明:
(1)当前版本中支持的image如下。
COE | os-distro |
Kubernetes | Fedora-atomic, CoreOS |
Swarm | Fedora-atomic |
Mesos | Ubuntu |
(2)当前版本支持的容器network-driver如下。
COE | Network-Driver | Default |
Kubernetes | Flannel | Flannel |
Swarm | Docker, Flannel | Flannel |
Mesos | Docker | Docker |
(3)当前版本支持的容器volume-driver如下。
COE | Volume-Driver | Default |
Kubernetes | Cinder | No Driver |
Swarm | Rexray | No Driver |
Mesos | Rexray | No Driver |
4.Magnum源码结构
说明:
api:以Pecan框架(http://www.pecanpy.org/)基础的API请求处理代码,接收到客户端请求后,进行解析转发或者直接处理。
cmd: 整个Magnum组件对外提供操作的入口。
common: 公共代码。
condutor: magnum-conductor接收到magnum-api消息后,在此处选择相应的driver进行下一步处理。
conf: 配置相关代码。
db: sqlalchemy相关代码,包括数据库migrating功能。
drviers: 后端各种driver(Kubernetes, Swarm以及Mesos)相关代码。
hacking: 供magnum单元测试使用的检测对象。
objects: 数据库model抽象,提供操作数据库功能。
service:周期性更新clusters状态至数据库。
servicegroup: 周期性更新magnum服务组状态至数据库。
tests: 单元测试相关代码。
5.Magnum代码流程分析
(1)启动脚本
安装完Magnum组件,会在系统/usr/bin目录下面生产4个可执行脚本,与源码文件setup.cfg中设置相对应,如下图所示。系统默认启动magnum-api和magnum-conductor脚本,magnum系统即可正常工作,magnum-db-manage和magnum-driver-manage可用于手动操作,完成相关任务。
magnum-api: 负责接收处理以及转发client的请求消息。
magnum-conductor: 负责接收magnum-api所发出的消息,进行cluster等具体操作。
magnum-db-manage: 负责数据库的stamp,upgrade,version相关操作。
magnum-driver-manage: 负责管理后端各种driver(Kubernetes, Swarm以及Mesos)相关配置。
(2)代码流程
如上图所示,Magnum逻辑功能主要三个方面.
(1)通过magnum-db-manage控制数据库的migrating,目前只支持sqlalchemy的backend, 位于源码文件setup.py, 如下图所示。
执行过程:调用源码文件magnum/cmd/db_manage.py:main, 之后调用magnum/db/migration.py直接操作,如下图所示。此过程较简单,不再深入。
(2)通过magnum-driver-manage脚本,调用源码文件magnum/cmd/driver_manage.py:main,之后调用magnum/drivers/driver.py, 管理drivers/目录下各种driver(Kubernetes, Swarm以及Mesos)的相关配置。此过程较简单,不再深入。
(3)magnum-api消息处理流程:通过magnum-api脚本,调用源码文件magnum/cmd/api.py,之后系统进入api目录完成消息的解析以及处理。整个api目录下的代码以Pecan为框架组成,如下图所示。
说明:
(1)magnum-api接收到消息后,经Middleware进行过滤。
(2)之后由Pecan Route转发消息至相应的分支进行处理。
(3)Cluster和Certificate分支相关的消息,被发送到消息队列服务端,由magnum-conductor进程处理。其它分支消息只需跟数据库进行交互。
magnum-conductor消息处理大致流程:此进程启动RPC service接受magnum-api发出的消息,之后转发到相应的endpoint进行处理,如下图所示,位于源码文件cmd/conductor.py。
之后跳转到与endpoint对应的conductor/handlers/目录下进行处理,如下图所示。
其中,ca_conductor.py:具体负责certificate相关消息处理,包括生成,存储,删除以及读取certificate操作。支持不同的backend来进行相关的certificate操作,位于源码文件setup.py, 如下图所示。
cluster_conductor.py:负责处理cluster create,update,delete操作,根据cluster的属性选择相应的后端driver(kuberntes, mesos或者swarm, 位于源码文件setup.py, 如下图所示),最后通过heat组件以template形式来执行cluster相关的操作。
conductor_listener.py:代表magnum-conductor alive状态,即相当于keepalive概念。
indirection_api.py:主要用于处理与数据库相关操作。
参考文章:
1.http://docs.openstack.org/developer/magnum/
2.https://wiki.openstack.org/wiki/Magnum
3.https://github.com/openstack/magnum
Openstack容器项目之Magnum的更多相关文章
- [ci]jenkins构建容器项目java-helloworld-非docker plugin模式
栗子思路说明: 不使用任何docker plugin 使用jenkins server本地(含mvn环境)构建,无jenkins slave jenkins server本地构建的war包,推送dep ...
- k8s与CICD--借助scp插件实现非容器项目的部署
一直没有时间完成drone系列文章.drone-wechat插件实现了一半,由于企业微信token申请比较麻烦,所以也没有进展.今天抽出时间,研究了一下scp插件,主要目的是实现非容器项目的部署.其实 ...
- OpenStack容器网络项目Kuryr(libnetwork)
转:https://www.aliyun.com/jiaocheng/518375.html 摘要:容器近几年非常流行,有很多项目都考虑将容器与SDN结合.Kuryr就是其中一个项目.Kuryr项目在 ...
- kolla管理openstack容器
本文以nova-api容器为例,说明kolla如何将nova-api配置文件传入容器,容器如何启动nova-api服务并读取配置文件 注:第一部分比较无趣,二三部分 会有意思一些 1. nova-ap ...
- 【Network】golang 容器项目 flannel/UDP相关资料
参考资料: flannel_百度搜索 Flannel首页.文档和下载 - 容器集群子网 - 开源中国社区 docker下基于flannel的overlay网络分析 - OPEN 开发经验库 flann ...
- 云计算之openstack ocata 项目搭建详细方法
之前写过一篇<openstack mitaka 配置详解>然而最近使用发现阿里不再提供m版本的源,所以最近又开始学习ocata版本,并进行总结,写下如下文档 OpenStack ocata ...
- OpenStack计费项目Cloudkitty系列详解(一)
云计算是一种按需付费的服务模式,虽然OpenStack前期在计量方面走了些“弯路”,但现在的ceilometer.gnocchi.aodh.panko项目的稳步并进算是让其峰回路转.然而,目前来看Op ...
- Visual Studio容器项目工程化心得
引言 关注博主的网友会看到我使用ASP.NET Core 容器化部署企业级项目的过程, 回想到开发过程中,鄙人有一些工程化心得, 分享给同学们. 项目工程化 因为本项目涉及单元测试Project.容器 ...
- OpenStack Smaug项目简介
1 项目简介 Smaug是一个OpenStack中提供应用数据保护服务的项目. 2 项目使命 在OpenStack中建立应用数据保护的标准和规范. 保护OpenStack中的任何资源以及资源的依赖项. ...
随机推荐
- STM32内置参照电压的使用(转)
源:STM32内置参照电压的使用 每个STM32芯片都有一个内部的参照电压,相当于一个标准电压测量点,在芯片内部连接到ADC1的通道17. 根据数据手册中的数据,这个参照电压的典型值是1.20V,最小 ...
- MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法 -摘自网络
错误:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 原因: 同一个i ...
- 查看错误日志发现有两个警告(ignored in --skip-name-resolve mode)
2016-08-02 17:30:26 17374 [Warning] 'user' entry '@losnau-223.com' ignored in --skip-name-resolve mo ...
- linux 下source、sh、bash、./执行脚本的区别
原文地址:http://blog.csdn.net/caesarzou/article/details/7310201 source命令用法: source FileName 作用:在当前bash环境 ...
- iOS 类库列表
1. LinqToObjectiveC #import "NSArray+LinqExtensions.h" 它为NSArray添加了许多方法,能让你用流式API来转换.排序.分 ...
- 在centos 6.5 x64中安装 spark-1.5.1
以下内容参考:http://blog.csdn.net/lovehuangjiaju/article/details/48494737 1.解压安装文件,设置环境变量 这里我们使用的安装文件是已经编译 ...
- robotium从入门到放弃 一 测试开发环境搭建
1.JDK的安装及环境变量的配置 配置JAVA的运行环境,添加完环境变量后,可以打开Windows命令处理程序窗口,通过执行命令java -version验证环境变量是否添加成功.如果添加成功会 ...
- div+CSS实现段落首行缩进两个字符
段落前面空两个字的距离,不要再使用空格了,用CSS实现段落首缩进两个字符.应该使用首行缩进text-indent.text-indent可以使得容器内首行缩进一定单位.比如中文段落一般每段前空两个汉字 ...
- YII 1.0 小功能总结
1.操作成功提示 只能使用一次,getFlash()取值以后,值就删除了 控制器中: Yii::app()->user->setFlash('success','修改成功'); 视图中: ...
- easyui datagrid行中点击a标签链接,行被选中,但是获取不到对应的参数
easyui中使用比较多的就是datagrid了,表格中添加连接,点击跳转,为比较常用的方式;往往在点及标签后调用getSeleted方法会失效; 一.初始代码: {field: 'id',title ...