cloud service 心得: openstack, cloudinit和puppet

最近在做关于云计算的东西,简单的记录下心得

用heat建个stack:

heat stack-create --template-file ${TEMPLATE} --environment-file${ENV_FILE} ${stack_name} 

--template-file 

heat的template描述了所用的所有组件资源以及组件资源之间的关系。这些资源包括:servers,floating ips, volumes, security groups, users and others.Heat管理这些组件的生命周期,当你需要对现在的部署做一些修改的时候,你只需要对template做一些修改即可。

这个文章不错,非常简单的例子,

http://www.aboutyun.com/thread-9438-1-1.html

有用的cmd:

nova image-list
+--------------------------------------+----------------------------------------------------+--------+--------------------------------------+
| ID                                  | Name                                             | Status |Server                              |
+--------------------------------------+----------------------------------------------------+--------+--------------------------------------+
| 5a557ae6-306c-40bd-ba41-980624aec073 | centos-70-raw                                    | ACTIVE |                                    |
| bb6bc4a4-e13b-4eed-900c-bd729f056fa4 | centos7-cloudinit-puppet                          |ACTIVE |                                     |
| f47c9f2c-460c-45f6-b81c-eded00db68b6 | centos7-cloudinit-puppet                          |ACTIVE |                                  

 

 nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs |RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0        |      | 1     | 1.0        | True      |
| 2  | m1.small  | 2048      | 20   | 0        |      | 1     | 1.0        | True      |
| 3  | m1.medium | 4096      | 40   | 0        |      | 2     | 1.0        | True      |
| 4  | m1.large  | 8192      | 80   | 0        |      | 4     | 1.0        | True      |

 

--environment-file

I see an Environmentas a container for anything that affects the behavior of the Template (kindalike structured parameters).

1.   So parameters can be written into anenvironment file or automatically inserted if you pass them on the cli.

2.   You define any non-default Providers in theEnvironment

3.   You can define any extra/non-keystonecredentials in the Environment

 

https://wiki.openstack.org/wiki/Heat/Environments

heat 和terraform, 最主要的区别是terraform goesfurther by being both cloud-agnostic and enabling multiple providers andservices to be combined and composed.

 

https://www.terraform.io/intro/vs/cloudformation.html

cloud-init

openstack会建好虚拟机,架好网络, 然后在虚拟机上会运行这个cloud-init 程序,最后才是puppet

这个文章介绍了heat cloudinit lifecycle

https://wiki.openstack.org/wiki/Heat/ApplicationDeployment

·       The user calls the Heat API to create astack ("heat stack-create ... myStack")

·       Heat engine generates a mime multipartdata blob that will be consumed by cloud-init

·       Heat engine asks nova to create aninstance with the cloud-init data

·       Nova selects a compute node to run theinstance with the cloud-init data

·       When the instance boots up, it runs thecloud-init script:

·       Download the data from the metadataserver

·       Splits the multiple parts into the/var/lib/cloud/ directory

·       Run the different cloud-init parts(resize the root filesystem, set the hostname, install the user's SSH key,etc.)

·       Runs the user's script (located at/var/lib/cloud/data/cfn-userdata), it can be any kind of script (Bash, Python,etc.) but at some point this script should call cfn-init.

·       cfn-init loads/var/lib/cloud/data/cfn-init-data (a copy of theMetadata->AWS::CloudFormation::Init->Config attribute from the AWStemplate) and can install packages, setup users & groups, create files,etc.

 

 

关于cloud-init 和puppet的关系,这篇文章不错:

http://stackoverflow.com/questions/11995290/why-do-people-use-puppet-chef-with-amazon-cloud-formation-instead-of-just-using

Highlight:

Is there an advantage over CloudInit? Yes,absolutely, many of them!

Sure, you can write top to bottom run onceCloudInit scripts to provision a server. But what happens when you need tochange a configuration file, add a user, update a package, or install a newpackage? You will end up logging into servers or writing scripts to do so, andinevitably an incongruous state of servers.

CloudInit is not configuration management.If you opt to begin using configuration management software, use cloud init forjust one task: to bootsrap the Puppet/Chef/other agent.

Puppet doesn't just help you automateinstalling packages, setup ssh keys, or tune your Tomcat heap. It ensures thestate of things. When a developer is troubleshooting a Java app at 3am andchanges your Tomcat config, Puppet will change it back. You can rapidly changethe version of Python for all or groups of nodes, and if someone installs adifferent version, Puppet will change it back.

When your application stack changes and youstart using, say RabbitMQ, or Jetty, or a new RDBMS, you can easily test anddeploy the changes across tens or thousands of servers.

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值