-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcluster.yaml
225 lines (212 loc) · 7.55 KB
/
cluster.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
heat_template_version: 2015-04-30
#License
#=======
# Copyright (c) 2015 Genome Research Ltd.
#
# Author: James Beal <[email protected]>
#
# This file is part of https://github.com/wtsi-ssg/os-cluster-internal-config
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. This program is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# http://www.yamllint.com/
# http://docs.openstack.org/developer/heat/template_guide/hot_guide.html
# https://gitlab.cern.ch/admluis/clouddocs/blob/56d3af4fde261bf42125038d4c6c835e576011e0/orchestration/advanced_concepts.md
# https://github.com/miguelgrinberg/heat-tutorial/blob/master/lib/keypair.yaml
# https://github.com/openstack/heat-templates/blob/master/hot/autoscaling.yaml
# http://docs.openstack.org/developer/heat/template_guide/hot_spec.html
# https://gist.github.com/arnaudmorinol/4d2c9ab52a97afd31f5b
# https://developer.rackspace.com/blog/openstack-orchestration-in-depth-part-4-scaling/
description: Deploy a cluster
parameters:
head-image:
type: string
label: Image name or ID
description: Image to be used for compute instance
default: 354a2c2b-3395-4fac-8c74-a9dea0500f4b
compute-image:
type: string
label: Image name or ID
description: Image to be used for compute instance
default: 3c8eaf84-cc3c-44af-8fe9-45b0e7effea8
head-flavor:
type: string
label: Flavor
description: Type of instance (flavor) to be used for the head node
default: m1.large
compute-flavor:
type: string
label: Flavor
description: Type of instance (flavor) to be used for the compute node
default: m1.small
key:
type: string
label: Key name
description: Name of key-pair to be used for compute instance
default: jb23_set2
timeout:
type: number
description: Timeout for WaitCondition, depends on your image and environment
default: 1200
compute-node-count:
type: number
description: How many compute nodes to spin up
default: 2
resources:
head_wait:
type: OS::Heat::WaitCondition
properties:
handle: {get_resource: wait_handle}
timeout: {get_param: timeout}
wait_handle:
type: OS::Heat::WaitConditionHandle
floating_ip:
type: OS::Nova::FloatingIP
properties:
pool: nova
keypair:
type: OS::Nova::KeyPair
properties:
name: local_root
save_private_key: true
ssh_and_icmp:
type: OS::Neutron::SecurityGroup
properties:
name: ssh_and_icmp
description: Ping and SSH
rules:
- protocol: icmp
- protocol: tcp
port_range_min: 22
port_range_max: 22
openlava:
type: OS::Neutron::SecurityGroup
properties:
name: openlava
description: openlava ports
rules:
- protocol: udp
port_range_min: 1024
port_range_max: 65535
- protocol: tcp
port_range_min: 1024
port_range_max: 65535
nfs_server_sec:
type: OS::Neutron::SecurityGroup
properties:
name: nfs_servers
description: nfs server
rules:
- protocol: tcp
port_range_min: 111
port_range_max: 111
- protocol: tcp
port_range_min: 1110
port_range_max: 1110
- protocol: tcp
port_range_min: 2049
port_range_max: 2049
- protocol: tcp
port_range_min: 4045
port_range_max: 4045
- protocol: udp
port_range_min: 111
port_range_max: 111
- protocol: udp
port_range_min: 1110
port_range_max: 1110
- protocol: udp
port_range_min: 2049
port_range_max: 2049
- protocol: udp
port_range_min: 4045
port_range_max: 4045
head:
type: OS::Nova::Server
properties:
image: { get_param: head-image }
flavor: { get_param: head-flavor }
key_name: { get_param: key }
name:
str_replace:
template: "base%-head"
params:
base%: { get_param: 'OS::stack_name' }
security_groups:
- { get_resource: ssh_and_icmp }
- { get_resource: nfs_server_sec }
- { get_resource: openlava }
user_data_format: RAW
user_data:
str_replace:
params:
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
__root_pub__: { get_attr: [keypair, public_key] }
__root_private__: { get_attr: [keypair, private_key] }
template: |
#!/bin/sh
# get the local ip address and put it in /etc/hosts
curl -s http://169.254.169.254/latest/meta-data/local-ipv4 | awk '{printf ("%s\t\tcloud-head\n",$1)}' >> /etc/hosts
echo cloud-head > /etc/hostname
hostname cloud-head
# Configure ssh
mkdir -R -p /root/.ssh/
echo "__root_pub__" > /root/.ssh/authorized_keys
echo "__root_private__" > /root/.ssh/id_dsa
chmod -R 700 /root/.ssh /opt/openlava-3.1/work
chown -R root /root/.ssh /opt/openlava-3.1/work
# Signal that the compute nodes can be started
wc_notify --data-binary '{"status": "SUCCESS"}'
head_floating_IP_att:
type: OS::Nova::FloatingIPAssociation
properties:
floating_ip: { get_resource: floating_ip }
server_id: { get_resource: head }
compute_group:
type: OS::Heat::ResourceGroup
depends_on: head_wait
properties:
count: { get_param: compute-node-count }
resource_def:
type: OS::Nova::Server
properties:
name: compute-%index%
image: { get_param: compute-image }
flavor: { get_param: compute-flavor }
key_name: { get_param: key }
security_groups:
- { get_resource: ssh_and_icmp }
- { get_resource: openlava }
user_data_format: RAW
user_data:
str_replace:
params:
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
__root_pub__: { get_attr: [keypair, public_key] }
__root_private__: { get_attr: [keypair, private_key] }
__head_ip__: { get_attr: [ head, first_address ] }
template: |
#!/bin/sh
NAME=`curl -s http://169.254.169.254/latest/meta-data/hostname`
IP_ADDR=` curl -s http://169.254.169.254/latest/meta-data/local-ipv4`
# get the local ip address and put it in /etc/hosts
#
echo "${IP_ADDR} ${NAME}" >> /etc/hosts
echo "__head_ip__ cloud-head" >> /etc/hosts
# Configure ssh
mkdir -p /root/.ssh/
echo "__root_pub__" > /root/.ssh/authorized_keys
echo "__root_private__" > /root/.ssh/id_dsa
chmod -R 700 /root/.ssh
echo "${NAME} ansible_ssh_host=${IP_ADDR}" > /tmp/ansible
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/ansible cloud-head:/root/host-list-$NAME
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no cloud-head "/root/head-run-ansible.sh"
( sleep 20 ; reboot )