Skip to content

Commit 0a4b052

Browse files
authored
Merge pull request #14 from stackhpc/group-resources-wip
Group resources wip
2 parents 8f3d065 + 79e4073 commit 0a4b052

17 files changed

+583
-23
lines changed

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ inventory generated.
3434
It defaults to `cluster`
3535

3636
`cluster_environment_nodenet`: An environment file specifying the resource to
37-
use for the per-node network, `Cluster:NodeNet`.
37+
use for the per-node network resource, `Cluster::NodeNet`. *NOTE*: This option is
38+
deprecated, in favour of resources for defining `nodenet_resource` within groups
39+
and a global default resource using `nodenet_resource` within `cluster_params`.
3840

3941
`cluster_environment_instance`: An environment file specifying the resource to
40-
use for the instances, `Cluster:Instance`.
42+
use for the instances, `Cluster::Instance`. *NOTE*: This option is deprecated,
43+
in favour of resources for specific groups through adding a definition for
44+
`node_resource` to the group, and a global default resource through
45+
defining `node_resource` whithin `cluster_params`.
4146

4247
`cluster_environment`: A list of environment files to use when creating the
4348
Heat stack.
@@ -77,7 +82,32 @@ Heat stack.
7782
* `security_groups`: Optional list of names or UUIDs of security groups to
7883
add the instances' ports to.
7984
* `floating_net`: Optional name or UUID of a neutron network to attach
80-
floating IPs to when the `nodenet-w-fip.yaml` environment is used.
85+
floating IPs to when the `Cluster::NodeNet1WithFIP` resource is used.
86+
87+
* `node_resource`: A resource name from the library of custom node resource
88+
names. This resource type is used as a default for groups which do not
89+
override with a specific node resource type.
90+
91+
Valid options include:
92+
93+
* `Cluster::Instance`: An instance with ephemeral storage only.
94+
This is the default.
95+
* `Cluster::InstanceWithVolume`: An instance provisioned with a Cinder volume.
96+
97+
* `nodenet_resource`: A resource name from the library of custom network
98+
resources for node networking. This resource type is used for groups that
99+
don't specify a network configuration for instances of the group.
100+
101+
Valid options include:
102+
103+
* `Cluster::NodeNet1`: A single network with no floating IP associated.
104+
This is the default.
105+
* `Cluster::NodeNet1WithFIP`: A single network with floating IP allocated
106+
and associated with the port.
107+
* `Cluster::NodeNet2`: Two network interfaces. The first two networks listed
108+
in `cluster_net` are used.
109+
* `Cluster::NodeNet3`: Three network interfaces. The first three networks listed
110+
in `cluster_net` are used.
81111

82112
`cluster_inventory`: After deployment, an inventory file is generated,
83113
which can be used in subsequent Ansible-driven configuration.
@@ -128,11 +158,17 @@ group and a `compute` group.
128158
cluster_net:
129159
- net: "internal"
130160
subnet: "internal"
161+
floating_net: "external"
162+
security_groups:
163+
- "default"
164+
- "slurm"
131165
cluster_groups:
132166
- name: "login"
133167
flavor: "compute-B"
134168
image: "CentOS7-OpenHPC"
135169
num_nodes: 1
170+
node_resource: "Cluster::InstanceWithVolume"
171+
node_resource: "Cluster::NodeNet1WithFIP"
136172
- name: "compute"
137173
flavor: "compute-A"
138174
image: "CentOS7-OpenHPC"
@@ -145,3 +181,4 @@ Author Information
145181
------------------
146182

147183
- Stig Telfer (<stig@stackhpc.com>)
184+
- Bharat Kunwar (<bharat@stackhpc.com>)

defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ cluster_auth:
55
cluster_cloud:
66
cluster_state: "present"
77
cluster_name: "cluster"
8-
cluster_environment_nodenet: "{{ role_path }}/files/environments/nodenet-1.yaml"
9-
cluster_environment_instance: "{{ role_path }}/files/environments/instance.yaml"
8+
cluster_environment_nodenet: "{{ role_path }}/files/environments/nodenet-library.yaml"
9+
cluster_environment_instance: "{{ role_path }}/files/environments/instance-library.yaml"
1010
cluster_environment:
1111
- "{{ cluster_environment_nodenet }}"
1212
- "{{ cluster_environment_instance }}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
resource_registry:
3+
Cluster::InstanceWithVolume: ../resources/instance-w-volume.yaml
4+
Cluster::Instance: ../resources/instance.yaml
5+
6+
# Under development
7+
Cluster::InstanceMultiNet: ../resources/instance-multi.yaml
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
resource_registry:
3+
Cluster::NodeNet: ../resources/nodenet-2-w-fip.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
resource_registry:
3+
Cluster::NodeNet: ../resources/nodenet-1.yaml # A backwards-compatible default
4+
Cluster::NodeNet1: ../resources/nodenet-1.yaml
5+
Cluster::NodeNet1WithFIP: ../resources/nodenet-w-fip.yaml
6+
Cluster::NodeNet1WithPreallocatedFIP: ../resources/nodenet-w-prealloc-fip.yaml
7+
Cluster::NodeNet2: ../resources/nodenet-2.yaml
8+
Cluster::NodeNet3: ../resources/nodenet-3.yaml

files/resources/cluster-group.yaml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,28 @@ parameters:
2626
cluster_net:
2727
type: json
2828
label: Network names and subnets to which the nodes should be attached
29+
cluster_node_resource:
30+
type: string
31+
label: Cluster-wide default to use for node resources
32+
constraints:
33+
- allowed_values:
34+
- "Cluster::Instance"
35+
- "Cluster::InstanceWithVolume"
36+
cluster_nodenet_resource:
37+
type: string
38+
label: Default node network resource for the cluster
39+
default: "Cluster::NodeNet"
40+
constraints:
41+
- allowed_values:
42+
- "Cluster::NodeNet"
43+
- "Cluster::NodeNet1"
44+
- "Cluster::NodeNet1WithFIP"
45+
- "Cluster::NodeNet2"
46+
- "Cluster::NodeNet3"
2947
group_idx:
3048
type: number
3149
label: Cluster group index
50+
3251

3352
conditions:
3453
volume_size_set:
@@ -41,14 +60,52 @@ conditions:
4160
expression: $.data.cluster_group.containsKey('volume_type')
4261
data:
4362
cluster_group: { get_param: [cluster_groups, {get_param: group_idx}] }
63+
node_resource_set:
64+
yaql:
65+
expression: $.data.cluster_group.containsKey('node_resource')
66+
data:
67+
cluster_group: { get_param: [cluster_groups, {get_param: group_idx}] }
68+
nodenet_resource_set:
69+
yaql:
70+
expression: $.data.cluster_group.containsKey('nodenet_resource')
71+
data:
72+
cluster_group: { get_param: [cluster_groups, {get_param: group_idx}] }
73+
nodenet_fips_set:
74+
yaql:
75+
expression: $.data.cluster_group.containsKey('nodenet_fips')
76+
data:
77+
cluster_group: { get_param: [cluster_groups, {get_param: group_idx}] }
4478

4579
resources:
80+
port_group:
81+
type: OS::Heat::ResourceGroup
82+
properties:
83+
count: { get_param: [cluster_groups, {get_param: group_idx}, num_nodes] }
84+
resource_def:
85+
type:
86+
if:
87+
- nodenet_resource_set
88+
- { get_param: [cluster_groups, {get_param: group_idx}, nodenet_resource ] }
89+
- { get_param: cluster_nodenet_resource }
90+
properties:
91+
cluster_net: { get_param: cluster_net }
92+
cluster_fips:
93+
if:
94+
- nodenet_fips_set
95+
- { get_param: [cluster_groups, {get_param: group_idx}, nodenet_fips ] }
96+
- []
97+
node_idx: "%index%"
98+
4699
node_group:
47100
type: OS::Heat::ResourceGroup
48101
properties:
49102
count: { get_param: [cluster_groups, {get_param: group_idx}, num_nodes] }
50103
resource_def:
51-
type: Cluster::Instance
104+
type:
105+
if:
106+
- node_resource_set
107+
- { get_param: [cluster_groups, {get_param: group_idx}, node_resource ] }
108+
- { get_param: cluster_node_resource }
52109
properties:
53110
name:
54111
list_join:
@@ -71,11 +128,14 @@ resources:
71128
key_name: { get_param: cluster_keypair }
72129
availability_zone: { get_param: cluster_az }
73130
config_drive: { get_param: cluster_config_drive }
74-
cluster_net: { get_param: cluster_net }
131+
group_node_ports: { get_attr: [port_group, networks] }
132+
group_node_ips: { get_attr: [port_group, primary_ip] }
133+
node_idx: "%index%"
75134

76135
outputs:
77136
group_data:
78137
description: Instance data for nodes in this group
79138
value:
80139
group: { get_param: [cluster_groups, {get_param: group_idx}, name] }
81140
nodes: { get_attr: [ node_group, instance_data ] }
141+
nodenet: { get_attr: [ port_group, networks ] }

files/resources/cluster-infra.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ parameters:
2727
cluster_net:
2828
type: json
2929
label: Network names and subnets to which the nodes should be attached
30+
node_resource:
31+
type: string
32+
label: Default node resource for the cluster
33+
default: "Cluster::Instance"
34+
constraints:
35+
- allowed_values:
36+
- "Cluster::Instance"
37+
- "Cluster::InstanceWithVolume"
38+
nodenet_resource:
39+
type: string
40+
label: Default node network resource for the cluster
41+
default: "Cluster::NodeNet"
42+
constraints:
43+
- allowed_values:
44+
- "Cluster::NodeNet"
45+
- "Cluster::NodeNet1"
46+
- "Cluster::NodeNet1WithFIP"
47+
- "Cluster::NodeNet2"
48+
- "Cluster::NodeNet3"
3049

3150
resources:
3251
cluster_group:
@@ -46,6 +65,8 @@ resources:
4665
cluster_groups: { get_param: cluster_groups }
4766
cluster_config_drive: { get_param: cluster_config_drive }
4867
cluster_net: { get_param: cluster_net }
68+
cluster_node_resource: { get_param: node_resource }
69+
cluster_nodenet_resource: { get_param: nodenet_resource }
4970
group_idx: "%index%"
5071

5172
outputs:

files/resources/instance-multi.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
heat_template_version: pike
3+
4+
description: >
5+
Heat stack containing a Nova instance.
6+
7+
parameters:
8+
name:
9+
type: string
10+
label: Instance name
11+
flavor:
12+
type: string
13+
label: Flavor name or UUID
14+
image:
15+
type: string
16+
label: Image name or UUID
17+
volume_size:
18+
type: number
19+
label: Volume size in GB
20+
volume_type:
21+
type: string
22+
label: Volume type
23+
key_name:
24+
type: string
25+
label: SSH key pair name
26+
availability_zone:
27+
type: string
28+
label: Availability zone
29+
default: nova
30+
config_drive:
31+
type: boolean
32+
label: Whether to provide metadata via a configdrive
33+
default: false
34+
group_node_ports:
35+
type: json
36+
label: Nested list of port resources for all nodes in this group
37+
group_node_ips:
38+
type: json
39+
label: List of primary IPs for all nodes in this group
40+
node_idx:
41+
type: number
42+
label: Resource group index of this node
43+
44+
conditions:
45+
ports_gt_1_yaql:
46+
yaql:
47+
data:
48+
group_node_ports: { get_param: group_node_ports }
49+
expression: $.data.group_node_ports[0].len() > 1
50+
ports_gt_1:
51+
not:
52+
equals:
53+
- ports_gt_1_yaql
54+
- False
55+
56+
ports_gt_2_yaql:
57+
yaql:
58+
data:
59+
group_node_ports: { get_param: group_node_ports }
60+
expression: $.data.group_node_ports[0].len() > 2
61+
ports_gt_2:
62+
not:
63+
equals:
64+
- ports_gt_2_yaql
65+
- False
66+
67+
resources:
68+
69+
instance:
70+
type: OS::Nova::Server
71+
properties:
72+
name: { get_param: name }
73+
flavor: { get_param: flavor }
74+
image: { get_param: image }
75+
key_name: { get_param: key_name }
76+
# FIXME: I would like to do this but Heat does not parse it:
77+
#networks: { get_param: [ group_node_ports, {get_param: node_idx} ] }
78+
#networks:
79+
# list_concat:
80+
# - []
81+
# - { get_param: [ group_node_ports, {get_param: node_idx} ] }
82+
#networks:
83+
# - { get_param: [ group_node_ports, {get_param: node_idx}, 0 ] }
84+
#networks:
85+
# yaql:
86+
# data:
87+
# group_node_ports: { get_param: group_node_ports }
88+
# node_idx: { get_param: node_idx }
89+
# expression: $.data.group_node_ports[$.data.node_idx]
90+
#
91+
# FIXME: this works but is obviously limited to one port:
92+
networks:
93+
- port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }
94+
#networks:
95+
# list_concat:
96+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 0, port ] }]
97+
# - if:
98+
# - ports_gt_1_yaql
99+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 1, port ] }]
100+
# - []
101+
# - if:
102+
# - False
103+
# - [port: { get_param: [ group_node_ports, {get_param: node_idx}, 2, port ] }]
104+
# - []
105+
106+
availability_zone: { get_param: availability_zone }
107+
config_drive: { get_param: config_drive }
108+
109+
outputs:
110+
OS::stack_id:
111+
description: ID of the Nova instance
112+
value: { get_resource: instance }
113+
114+
instance_data:
115+
description: ID of the primary IP
116+
value:
117+
name: {get_param: name}
118+
ip: {get_param: [group_node_ips, {get_param: node_idx}]}
119+
id: {get_resource: instance}
120+
ports_gt_1: {equals: [ports_gt_1_yaql, True]}

0 commit comments

Comments
 (0)