Merge "Refactor Mesos templates"

This commit is contained in:
Jenkins 2015-11-23 12:09:58 +00:00 committed by Gerrit Code Review
commit 0472fa8173
5 changed files with 185 additions and 97 deletions

View File

@ -119,7 +119,9 @@ You can get the ip address of the Mesos master using the
::
$ heat output-show my-mesos-cluster mesos_master
"192.168.200.86"
[
"192.168.200.86"
]
You can ssh into that server as the ``ubuntu`` user:
@ -164,7 +166,7 @@ Docker container.
"cmd": "while sleep 10; do date -u +%T; done"
}
END
$ MASTER_IP=$(heat output-show my-mesos-cluster mesos_master | tr -d '"')
$ MASTER_IP=$(heat output-show my-mesos-cluster api_address | tr -d '"')
$ curl -X POST -H "Content-Type: application/json" \
http://${MASTER_IP}:8080/v2/apps -d@app.json

View File

@ -651,7 +651,7 @@ class UbuntuMesosTemplateDefinition(BaseTemplateDefinition):
self.add_output('mesos_master_private',
bay_attr=None)
self.add_output('mesos_master',
bay_attr=None)
bay_attr='master_addresses')
self.add_output('mesos_slaves_private',
bay_attr=None)
self.add_output('mesos_slaves',

View File

@ -66,16 +66,6 @@ parameters:
resources:
master_wait_handle:
type: OS::Heat::WaitConditionHandle
master_wait_condition:
type: OS::Heat::WaitCondition
depends_on: mesos_master
properties:
handle: {get_resource: master_wait_handle}
timeout: {get_param: wait_condition_timeout}
######################################################################
#
# network resources. allocate a network and router for our server.
@ -143,96 +133,40 @@ resources:
######################################################################
#
# software configs. these are components that are combined into
# a multipart MIME user-data archive.
# Mesos masters. This is a resource group that will create 1 master.
#
write_heat_params:
type: OS::Heat::SoftwareConfig
mesos_masters:
type: OS::Heat::ResourceGroup
depends_on:
- extrouter_inside
properties:
group: ungrouped
config:
str_replace:
template: {get_file: fragments/write-heat-params-master.yaml}
params:
"$MESOS_MASTER_IP": {get_attr: [mesos_master_eth0, fixed_ips, 0, ip_address]}
"$CLUSTER_NAME": {get_param: cluster_name}
configure_mesos:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/configure-mesos-master.sh}
start_services:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/start-services-master.sh}
master_wc_notify:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config:
str_replace:
template: |
#!/bin/bash -v
wc_notify --data-binary '{"status": "SUCCESS"}'
params:
wc_notify: {get_attr: [master_wait_handle, curl_cli]}
mesos_master_init:
type: OS::Heat::MultipartMime
properties:
parts:
- config: {get_resource: write_heat_params}
- config: {get_resource: configure_mesos}
- config: {get_resource: start_services}
- config: {get_resource: master_wc_notify}
count: 1
resource_def:
type: mesosmaster.yaml
properties:
ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image}
master_flavor: {get_param: master_flavor}
external_network: {get_param: external_network}
cluster_name: {get_param: cluster_name}
wait_condition_timeout: {get_param: wait_condition_timeout}
fixed_network: {get_resource: fixed_network}
fixed_subnet: {get_resource: fixed_subnet}
secgroup_base_id: {get_resource: secgroup_base}
secgroup_mesos_id: {get_resource: secgroup_mesos}
######################################################################
#
# Mesos master server.
# Mesos slaves. This is a resource group that will initially
# create <number_of_slaves> slaves, and needs to be manually scaled.
#
mesos_master:
type: OS::Nova::Server
depends_on:
- extrouter_inside
properties:
image: {get_param: server_image}
flavor: {get_param: master_flavor}
key_name: {get_param: ssh_key_name}
user_data_format: RAW
user_data: {get_resource: mesos_master_init}
networks:
- port: {get_resource: mesos_master_eth0}
mesos_master_eth0:
type: OS::Neutron::Port
properties:
network: {get_resource: fixed_network}
security_groups:
- {get_resource: secgroup_base}
- {get_resource: secgroup_mesos}
fixed_ips:
- subnet: {get_resource: fixed_subnet}
replacement_policy: AUTO
mesos_master_floating:
type: OS::Neutron::FloatingIP
depends_on:
- extrouter_inside
properties:
floating_network: {get_param: external_network}
port_id: {get_resource: mesos_master_eth0}
mesos_slaves:
type: OS::Heat::ResourceGroup
depends_on:
- extrouter_inside
- master_wait_condition
- mesos_masters
properties:
count: {get_param: number_of_slaves}
resource_def:
@ -243,7 +177,7 @@ resources:
slave_flavor: {get_param: slave_flavor}
fixed_network: {get_resource: fixed_network}
fixed_subnet: {get_resource: fixed_subnet}
mesos_master_ip: {get_attr: [mesos_master_eth0, fixed_ips, 0, ip_address]}
mesos_master_ip: {'Fn::Select': [0, {get_attr: [mesos_masters, mesos_master_ip]}]}
external_network: {get_param: external_network}
wait_condition_timeout: {get_param: wait_condition_timeout}
executor_registration_timeout: {get_param: executor_registration_timeout}
@ -251,18 +185,18 @@ resources:
outputs:
api_address:
value: {get_attr: [mesos_master_floating, floating_ip_address]}
value: {'Fn::Select': [0, {get_attr: [mesos_masters, mesos_master_external_ip]}]}
description: >
This is the API endpoint of the Mesos master. Use this to access
the Mesos API from outside the cluster.
mesos_master_private:
value: {get_attr: [mesos_master_eth0, fixed_ips, 0, ip_address]}
value: {get_attr: [mesos_masters, mesos_master_ip]}
description: >
This is a list of the "private" addresses of all the Mesos masters.
mesos_master:
value: {get_attr: [mesos_master_floating, floating_ip_address]}
value: {get_attr: [mesos_masters, mesos_master_external_ip]}
description: >
This is the "public" ip address of the Mesos master server. Use this address to
log in to the Mesos master via ssh or to access the Mesos API

View File

@ -0,0 +1,150 @@
heat_template_version: 2013-05-23
description: >
This is a nested stack that defines a single Mesos master, This stack is
included by a ResourceGroup resource in the parent template
(mesoscluster.yaml).
parameters:
server_image:
type: string
description: glance image used to boot the server
master_flavor:
type: string
default: m1.small
description: flavor to use when booting the server
ssh_key_name:
type: string
description: name of ssh key to be provisioned on our server
external_network:
type: string
description: uuid/name of a network to use for floating ip addresses
cluster_name:
type: string
description: human readable name for the mesos cluster
wait_condition_timeout:
type: number
description: timeout for the Wait Conditions
# The following are all generated in the parent template.
fixed_network:
type: string
description: Network from which to allocate fixed addresses.
fixed_subnet:
type: string
description: Subnet from which to allocate fixed addresses.
secgroup_base_id:
type: string
description: ID of the security group for base.
secgroup_mesos_id:
type: string
description: ID of the security group for mesos master.
resources:
master_wait_handle:
type: OS::Heat::WaitConditionHandle
master_wait_condition:
type: OS::Heat::WaitCondition
depends_on: mesos_master
properties:
handle: {get_resource: master_wait_handle}
timeout: {get_param: wait_condition_timeout}
######################################################################
#
# software configs. these are components that are combined into
# a multipart MIME user-data archive.
#
write_heat_params:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config:
str_replace:
template: {get_file: fragments/write-heat-params-master.yaml}
params:
"$MESOS_MASTER_IP": {get_attr: [mesos_master_eth0, fixed_ips, 0, ip_address]}
"$CLUSTER_NAME": {get_param: cluster_name}
configure_mesos:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/configure-mesos-master.sh}
start_services:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config: {get_file: fragments/start-services-master.sh}
master_wc_notify:
type: OS::Heat::SoftwareConfig
properties:
group: ungrouped
config:
str_replace:
template: |
#!/bin/bash -v
wc_notify --data-binary '{"status": "SUCCESS"}'
params:
wc_notify: {get_attr: [master_wait_handle, curl_cli]}
mesos_master_init:
type: OS::Heat::MultipartMime
properties:
parts:
- config: {get_resource: write_heat_params}
- config: {get_resource: configure_mesos}
- config: {get_resource: start_services}
- config: {get_resource: master_wc_notify}
######################################################################
#
# Mesos master server.
#
mesos_master:
type: OS::Nova::Server
properties:
image: {get_param: server_image}
flavor: {get_param: master_flavor}
key_name: {get_param: ssh_key_name}
user_data_format: RAW
user_data: {get_resource: mesos_master_init}
networks:
- port: {get_resource: mesos_master_eth0}
mesos_master_eth0:
type: OS::Neutron::Port
properties:
network: {get_param: fixed_network}
security_groups:
- {get_param: secgroup_base_id}
- {get_param: secgroup_mesos_id}
fixed_ips:
- subnet: {get_param: fixed_subnet}
replacement_policy: AUTO
mesos_master_floating:
type: OS::Neutron::FloatingIP
properties:
floating_network: {get_param: external_network}
port_id: {get_resource: mesos_master_eth0}
outputs:
mesos_master_ip:
value: {get_attr: [mesos_master_eth0, fixed_ips, 0, ip_address]}
mesos_master_external_ip:
value: {get_attr: [mesos_master_floating, floating_ip_address]}

View File

@ -499,7 +499,8 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
mesos_def = tdef.UbuntuMesosTemplateDefinition()
expected_api_address = 'updated_address'
expected_node_addresses = ['ex_minion', 'address']
expected_node_addresses = ['ex_slave', 'address']
expected_master_addresses = ['ex_master', 'address']
outputs = [
{"output_value": expected_api_address,
@ -508,7 +509,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
{"output_value": ['any', 'output'],
"description": "No description given",
"output_key": "mesos_master_private"},
{"output_value": ['any', 'output'],
{"output_value": expected_master_addresses,
"description": "No description given",
"output_key": "mesos_master"},
{"output_value": ['any', 'output'],
@ -527,3 +528,4 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
self.assertEqual(expected_api_address, mock_bay.api_address)
self.assertEqual(expected_node_addresses, mock_bay.node_addresses)
self.assertEqual(expected_master_addresses, mock_bay.master_addresses)