配置heat AutoScalingMultiAZSample.template 模板

OS : Ubuntu 13.10

OpenStack : Havana

Controller : 192.168.1.101

All-In-One

1. 下載F17-x86_64-cfntools.qcow2

wget http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F17-x86_64-cfntools.qcow2

2. 導入image到glance

xianghui@xianghui:~/Workplace$ glance image-create --name F17-x86_64-cfntools --container-format=bare --disk-format=qcow2 
--is-public=True < F17-x86_64-cfntools.qcow2 
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | afab0f79bac770d61d24b4d0560b5f70     |
| container_format | bare                                 |
| created_at       | 2014-01-01T08:01:22                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | d8e546e4-eda3-4e21-b55b-a08f08f1a65c |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | F17-x86_64-cfntools                  |
| owner            | e9b15a713fde4f6681771543e147018a     |
| protected        | False                                |
| size             | 476704768                            |
| status           | active                               |
| updated_at       | 2014-01-01T08:01:25                  |
+------------------+--------------------------------------+

3. 配置neutron flat network

xianghui@xianghui:~/Workplace$ neutron net-list
+--------------------------------------+---------+--------------------------------------------------+
| id                                   | name    | subnets                                          |
+--------------------------------------+---------+--------------------------------------------------+
| 0e59c487-5f1f-4489-b65c-c6f859fb6a22 | flat-50 | ab493af5-f5e1-405f-81e4-82ab627a9099 50.0.0.0/24 |
+--------------------------------------+---------+--------------------------------------------------+

4. 配置heat(/etc/heat/heat.conf)

[DEFAULT]

use_syslog = False
debug = True
auth_encryption_key = e27780df1696556366a0b7dbaaee6585
heat_watch_server_url = http://192.168.1.101:8003
heat_waitcondition_server_url = http://192.168.1.101:8000/v1/waitcondition
heat_metadata_server_url = http://192.168.1.101:8000

rabbit_password = e470d73e28db023218ab
rabbit_host = localhost

[database]
connection = mysql://root:[email protected]/heat?charset=utf8 

[ec2authtoken]
keystone_ec2_uri = http://192.168.1.101:5000/v2.0/ec2tokens
auth_uri = http://192.168.1.101:5000/v2.0

[heat_api_cloudwatch]
bind_port = 8003
bind_host = 192.168.1.101

[heat_api]
bind_port = 8004
bind_host = 192.168.1.101

[heat_api_cfn]
bind_port = 8000
bind_host = 192.168.1.101

[keystone_authtoken]
signing_dir = /var/cache/heat
admin_password = admin
admin_user = heat
admin_tenant_name = service
cafile =
auth_uri = http://192.168.1.101:5000/v2.0
auth_protocol = http
auth_port = 35357
auth_host = 192.168.1.101

5. 重啓 heat services

xianghui@xianghui:~/Workplace/heat/templates$ /usr/bin/python /usr/local/bin/heat-api -d --config-file /etc/heat/heat.conf
xianghui@xianghui:~/Workplace/heat/templates$ /usr/bin/python /usr/local/bin/heat-api-cfn -d --config-file /etc/heat/heat.conf
xianghui@xianghui:~/Workplace/heat/templates$ /usr/bin/python /usr/local/bin/heat-engine -d --config-file /etc/heat/heat.conf
xianghui@xianghui:~/Workplace/heat/templates$ /usr/bin/python /usr/local/bin/heat-api-cloudwatch -d --config-file /etc/heat/heat.conf


6. 下載AutoScalingMultiAZSample.template

git clone https://github.com/steveb/heat.git
xianghui@xianghui:~/Workplace/heat/templates$ cat AutoScalingMultiAZSample.template
{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "AWS CloudFormation Sample Template",

  "Parameters" : {

    "KeyName" : {
      "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
      "Type" : "String"
    },

....

7. 配置169.254.169.254

# 爲flat network 50.0.0.0/24添加網關
xianghui@xianghui:~/Workplace$  sudo ifconfig br-eth1:3 50.0.0.1
br-eth1:3 Link encap:Ethernet  HWaddr f0:de:f1:1a:2c:e5  
          inet addr:50.0.0.1  Bcast:50.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING  MTU:1500  Metric:1

# 修改iptables
xianghui@xianghui:~/Workplace$ sudo iptables -t nat -A PREROUTING -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT 
--to-destination 192.168.1.101:8775
xianghui@xianghui:~/Workplace$ sudo iptables-save

8. 創建 heat stack "autoscale-3"

xianghui@xianghui:~/Workplace$ heat stack-create autoscale-3 --parameters="KeyName=userkey"  

--template-file=./AutoScalingMultiAZSample.template

xianghui@xianghui:~/Workplace$ heat list
+--------------------------------------+-------------+--------------------+----------------------+
| id                                   | stack_name  | stack_status       | creation_time        |
+--------------------------------------+-------------+--------------------+----------------------+
| 800f50a6-b65c-4502-b459-60b4ffaff640 | autoscale-3 | CREATE_FAILED      | 2014-01-02T10:06:43Z |
+--------------------------------------+-------------+--------------------+----------------------+


xianghui@xianghui:~/Workplace$ heat resource-list autoscale-3
+--------------------------+-----------------------------------------+-----------------+----------------------+
| resource_name            | resource_type                           | resource_status | updated_time         |
+--------------------------+-----------------------------------------+-----------------+----------------------+
| LaunchConfig             | AWS::AutoScaling::LaunchConfiguration   | CREATE_COMPLETE | 2014-01-02T10:06:43Z |
| ElasticLoadBalancer      | AWS::ElasticLoadBalancing::LoadBalancer | CREATE_FAILED   | 2014-01-02T10:17:45Z |
| MEMAlarmHigh             | AWS::CloudWatch::Alarm                  | INIT_COMPLETE   | 2014-01-02T11:01:42Z |
| MEMAlarmLow              | AWS::CloudWatch::Alarm                  | INIT_COMPLETE   | 2014-01-02T11:01:42Z |
| WebServerGroup           | AWS::AutoScaling::AutoScalingGroup      | INIT_COMPLETE   | 2014-01-02T11:01:42Z |
| WebServerScaleDownPolicy | AWS::AutoScaling::ScalingPolicy         | INIT_COMPLETE   | 2014-01-02T11:01:42Z |
| WebServerScaleUpPolicy   | AWS::AutoScaling::ScalingPolicy         | INIT_COMPLETE   | 2014-01-02T11:01:42Z |
+--------------------------+-----------------------------------------+-----------------+----------------------+

發現failed, 原來是沒有配 ElasticLoadBalancer, 爲了讓模板成功暫時刪掉涉及“ElasticLoadBalancer”的部分,如下:

    ,
    "LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]


    ,
    "ElasticLoadBalancer" : {
      "Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
      "Properties" : {
        "AvailabilityZones" : { "Fn::GetAZs" : "" },
        "Listeners" : [ {
          "LoadBalancerPort" : "80",
          "InstancePort" : "80",
          "Protocol" : "HTTP"
        } ],
        "HealthCheck" : {
          "Target" : "HTTP:80/",
          "HealthyThreshold" : "3",
          "UnhealthyThreshold" : "5",
          "Interval" : "30",
          "Timeout" : "5"
        }
      }
    },

重新創建後,成功了!

xianghui@xianghui:~/Workplace$ heat stack-create autoscale-7 --parameters="KeyName=userkey"  
--template-file=./AutoScalingMultiAZSample.template


xianghui@xianghui:~/Workplace$ heat list
+--------------------------------------+-------------+--------------------+----------------------+
| id                                   | stack_name  | stack_status       | creation_time        |
+--------------------------------------+-------------+--------------------+----------------------+
| 800f50a6-b65c-4502-b459-60b4ffaff640 | autoscale-3 | CREATE_FAILED      | 2014-01-02T10:06:43Z |
| 235e09ec-e4f5-49fc-91e5-b239ac03e68b | autoscale-7 | CREATE_COMPLETE    | 2014-01-02T10:25:16Z |
+--------------------------------------+-------------+--------------------+----------------------+
xianghui@xianghui:~/Workplace$ heat resource-list autoscale-7
+--------------------------+---------------------------------------+-----------------+----------------------+
| resource_name            | resource_type                         | resource_status | updated_time         |
+--------------------------+---------------------------------------+-----------------+----------------------+
| LaunchConfig             | AWS::AutoScaling::LaunchConfiguration | CREATE_COMPLETE | 2014-01-02T10:25:16Z |
| WebServerGroup           | AWS::AutoScaling::AutoScalingGroup    | CREATE_COMPLETE | 2014-01-02T10:26:28Z |
| WebServerScaleDownPolicy | AWS::AutoScaling::ScalingPolicy       | CREATE_COMPLETE | 2014-01-02T10:26:31Z |
| WebServerScaleUpPolicy   | AWS::AutoScaling::ScalingPolicy       | CREATE_COMPLETE | 2014-01-02T10:26:31Z |
| MEMAlarmHigh             | AWS::CloudWatch::Alarm                | CREATE_COMPLETE | 2014-01-02T10:26:32Z |
| MEMAlarmLow              | AWS::CloudWatch::Alarm                | CREATE_COMPLETE | 2014-01-02T10:26:32Z |
+--------------------------+---------------------------------------+-----------------+----------------------+

xianghui@xianghui:~/Workplace/devstack$ nova list
+--------------------------------------+-------------------------------------------------------+---------+------------+-------------+------------------+
| ID                                   | Name                                                  | Status  | Task State | Power State | Networks         |
+--------------------------------------+-------------------------------------------------------+---------+------------+-------------+------------------+
| 3a61a869-95c9-4f2b-8f42-661c100c92af | au-ServerGroup-m4jxrrumtumn-hupiztjnvqx2-etgf35x7arfd | ACTIVE  | None       | Running     | flat-50=50.0.0.5 |
| 9275e6cf-6e7a-4d26-8743-e7242614a1d6 | au-ServerGroup-x6mwhbaznsf4-mgsjqaa3z7ko-mu665csbnuzj | ACTIVE  | None       | Running     | flat-50=50.0.0.7 |
+--------------------------------------+-------------------------------------------------------+---------+------------+-------------+------------------+


Referrence:

http://docs.openstack.org/havana/install-guide/install/apt/content/heat-install.html
https://wiki.openstack.org/wiki/Heat/AWS-to-OpenStack-resource-mapping-in-templates
http://docs.openstack.org/developer/heat/template_guide/
https://wiki.openstack.org/wiki/ReleaseNotes/Havana
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb.html
http://docs.openstack.org/image-guide/content/image-formats.html
https://wiki.openstack.org/wiki/ReleaseNotes/Havana


9. Vm 啓動過程




Comments:

Are you using nova-networking or neutron?

I'll explain how this works for the record:

when you configure heat there is a config option, it should be something like: heat_waitcondition_server_url = http://<heat-api-cfn ip="">:8000/v1/waitcondition</heat-api-cfn>
you create a stack with a waitcondition in it.
some metadata is saved in heat for the waitcondition
an ec2signed url is passed to the vm in the userdata
when cfn-signal is called it does a PUT to the ec2signed url
heat-engine modifies the waitcondition metadata.
So the only things you can really check are:

is heat_waitcondition_server_url set correctly
has cfn-signal been called
did the call make it to heat-api-cfn (check the logs)
As I said earlier, if you have this issue it is normally because cfn-signal was called but it did not make it to heat-api-cfn because of networking issues.

-Angus

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章