diff --git a/heat_templates/icehouse/compute_node.yaml b/heat_templates/icehouse/compute_node.yaml new file mode 100644 index 0000000..149e0b6 --- /dev/null +++ b/heat_templates/icehouse/compute_node.yaml @@ -0,0 +1,149 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template to deploy one compute node into an xisting neutron tenant network and + assign floating IP address to the server so they are routable from the + public network. + +parameters: + key_name: + type: string + description: Name of keypair to assign to servers + image: + type: string + description: Name of image to use for servers + flavor: + type: string + description: Flavor to use for servers + public_net_id: + type: string + description: > + ID of public network for which floating IP addresses will be allocated + private_net_id: + type: string + description: ID of private network into which servers get deployed + private_subnet_id: + type: string + description: ID of private sub network into which servers get deployed + master_node_ip: + type: string + description: IP address of the Master node. + +resources: + + node_wait_handle: + type: "AWS::CloudFormation::WaitConditionHandle" + + node_wait_condition: + type: "AWS::CloudFormation::WaitCondition" + depends_on: + - compute_node + properties: + Handle: + get_resource: node_wait_handle + Timeout: "1200" + + secgroup_all_open: + type: "OS::Neutron::SecurityGroup" + properties: + rules: + - protocol: icmp + - protocol: tcp + - protocol: udp + + compute_node: + type: OS::Nova::Server + properties: + name: compute + image: + get_param: image + flavor: + get_param: flavor + key_name: + get_param: key_name + user_data_format: RAW + user_data: + str_replace: + template: | + #!/bin/sh + + yum -y remove NetworkManager + chkconfig network on + + cat > /etc/yum.repos.d/torque.repo << EOF + [torque] + name=torque + baseurl=http://192.168.95.200/install/post/otherpkgs/el7/torque + enabled=1 + gpgcheck=0 + EOF + + yum -y install torque-client + + chkconfig trqauthd on + chkconfig pbs_mom on + + echo $MASTER_NODE_IP > /var/spool/torque/server_name + + cat > /var/spool/torque/mom_priv/config << EOF + $logevent 0x1ff + + $pbsserver $MASTER_NODE_IP + EOF + + service trquathd start + service pbs_mom start + + myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) + myip_last_octet=${myip##*.} + + cat > /tmp/wait-data << EOF + { + "Status" : "SUCCESS", + "Reason" : "Setup Complete", + "UniqueId" : "None", + "Data" : "OK" + } + EOF + curl -T /tmp/wait-data '$WAIT_HANDLE' + params: + "$MASTER_NODE_IP": + get_param: master_node_ip + "$WAIT_HANDLE": + get_resource: node_wait_handle + networks: + - port: + get_resource: compute_node_eth0 + + compute_node_eth0: + type: OS::Neutron::Port + properties: + network_id: + get_param: private_net_id + fixed_ips: + - subnet_id: + get_param: private_subnet_id + security_groups: + - get_resource: secgroup_all_open + + compute_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: + get_param: public_net_id + port_id: + get_resource: compute_node_eth0 + +outputs: + compute_node_name: + description: The name of the compute node + value: { get_attr: [ compute_node, instance_name ] } + compute_node_ip: + description: IP address of compute node in private network + value: { get_attr: [ compute_node_eth0, fixed_ips, 0, ip_address ] } + compute_node_external_ip: + description: Floating IP address of compute node in public network + value: { get_attr: [ compute_floating_ip, floating_ip_address ] } + compute_node_show: + description: Show all attributes + value: { get_attr: [ compute_node, show ] } diff --git a/heat_templates/icehouse/hpc.yaml b/heat_templates/icehouse/hpc.yaml new file mode 100644 index 0000000..202ef7e --- /dev/null +++ b/heat_templates/icehouse/hpc.yaml @@ -0,0 +1,269 @@ +heat_template_version: 2013-05-23 + +description: > + This template will boot a Kubernetes cluster with one or more + minions (as specified by the number_of_minions parameter, which + defaults to "2"). + +parameters: + + # + # REQUIRED PARAMETERS + # + key_name: + type: string + description: name of ssh key to be provisioned on our server + + public_net_id: + type: string + description: uuid of a network to use for floating ip addresses + + # + # OPTIONAL PARAMETERS + # + image: + type: string + default: centos7 + description: glance image used to boot the server + + flavor: + type: string + default: m1.small + description: flavor to use when booting the server + + dns_nameserver: + type: string + description: address of a dns nameserver reachable in your environment + default: 8.8.8.8 + + number_of_compute_nodes: + type: string + description: how many compute nodes to spawn + default: 10 + +resources: + + master_wait_handle: + type: "AWS::CloudFormation::WaitConditionHandle" + + master_wait_condition: + type: "AWS::CloudFormation::WaitCondition" + depends_on: + - master_node + properties: + Handle: + get_resource: master_wait_handle + Timeout: "1200" + + ###################################################################### + # + # network resources. allocate a network and router for our server. + # it would also be possible to take advantage of existing network + # resources (and have the deployer provide network and subnet ids, + # etc, as parameters), but I wanted to minmize the amount of + # configuration necessary to make this go. + fixed_net: + type: "OS::Neutron::Net" + + # This is the subnet on which we will deploy our server. + fixed_subnet: + type: "OS::Neutron::Subnet" + properties: + cidr: 10.0.9.0/24 + network_id: { get_resource: fixed_net } + dns_nameservers: [{ get_param: dns_nameserver }] + + # create a router attached to the external network provided as a + # parameter to this stack. + extrouter: + type: "OS::Neutron::Router" + properties: + external_gateway_info: + network: + get_param: public_net_id + + # attached fixed_subnet to our extrouter router. + extrouter_inside: + type: "OS::Neutron::RouterInterface" + properties: + router_id: + get_resource: extrouter + subnet_id: { get_resource: fixed_subnet } + + ###################################################################### + # + # security groups. we need to permit network traffic of various + # sorts. + # + + secgroup_base: + type: "OS::Neutron::SecurityGroup" + properties: + rules: + - protocol: icmp + - protocol: tcp + port_range_min: 22 + port_range_max: 22 + + secgroup_compute: + type: "OS::Neutron::SecurityGroup" + properties: + rules: + - protocol: tcp + port_range_min: 22 + port_range_max: 22 + - protocol: tcp + port_range_min: 4001 + port_range_max: 4001 + + ###################################################################### + # + # databases server. this sets up a MySQL server + # + master_node: + type: "OS::Nova::Server" + depends_on: + - extrouter_inside + properties: + name: master + image: + get_param: image + flavor: + get_param: flavor + key_name: + get_param: key_name + networks: + - port: + get_resource: master_node_eth0 + user_data_format: RAW + user_data: + str_replace: + template: | + #!/bin/sh + + yum -y upgrade + + cat > /etc/yum.repos.d/torque.repo << EOF + [torque] + name=torque + baseurl=http://192.168.95.200/install/post/otherpkgs/el7/torque + enabled=1 + gpgcheck=0 + EOF + + yum -y install torque-server torque-scheduler + + chkconfig trqauthd on + chkconfig pbs_server on + chkconfig pbs_sched on + + myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) + + mkdir -p /var/spool/torque/server_priv + echo $myip > /var/spool/torque/server_name + rm -rf /var/spool/torque/server_priv/nodes + mkdir -p /var/spool/torque/checkpoint + + echo ${COMP_NODE_ADDRESSES} + echo ${COMP_NODE_NAMES} + + array1=(${COMP_NODE_ADDRESSES// / }) + array2=(${COMP_NODE_NAMES// / }) + + length=${#array1[@]} + + for ((i=0;i<=$length;i++)); do + echo -e "${array1[$i]} ${array2[$i]}" + done >> /etc/hosts + + echo $myip `hostname` >> /etc/hosts + + pbs_server -t create -f + + for node in $(echo ${COMP_NODE_NAMES}) + do + echo $node >> /var/spool/torque/server_priv/nodes + done + + service trqauthd restart + service pbs_server restart + service pbs_sched restart + + qmgr -c "c q testq" + qmgr -c "s q testq queue_type=e" + qmgr -c "s q testq enabled=t" + qmgr -c "s q testq started=t" + qmgr -c "s s scheduling=true" + + cat > /tmp/wait-data << EOF + { + "Status" : "SUCCESS", + "Reason" : "Setup Complete", + "UniqueId" : "None", + "Data" : "OK" + } + EOF + curl -T /tmp/wait-data '$WAIT_HANDLE' + params: + # NB: For this to work you need a version of Heat that + # includes https://review.openstack.org/#/c/121139/ + "$COMP_NODE_ADDRESSES": { "Fn::Join": [ " ", { get_attr: [compute_nodes, compute_node_ip] } ] } + "$COMP_NODE_NAMES": { "Fn::Join": [ " " , { get_attr: [compute_nodes, compute_node_name] } ] } + "$WAIT_HANDLE": + get_resource: master_wait_handle + + master_node_eth0: + type: "OS::Neutron::Port" + properties: + network_id: + get_resource: fixed_net + security_groups: + - get_resource: secgroup_base + - get_resource: secgroup_compute + fixed_ips: + - subnet_id: + get_resource: fixed_subnet + + master_node_floating: + type: "OS::Neutron::FloatingIP" + depends_on: + - extrouter_inside + properties: + floating_network_id: + get_param: public_net_id + port_id: + get_resource: master_node_eth0 + + compute_nodes: + type: "OS::Heat::ResourceGroup" + depends_on: + - extrouter_inside + properties: + count: {get_param: number_of_compute_nodes} + resource_def: + type: compute_node.yaml + properties: + key_name: {get_param: key_name} + image: {get_param: image} + flavor: {get_param: flavor} + private_net_id: {get_resource: fixed_net} + private_subnet_id: {get_resource: fixed_subnet} + public_net_id: {get_param: public_net_id} + master_node_ip: {get_attr: [master_node_eth0, fixed_ips, 0, ip_address]} + +outputs: + + master_node_external: + value: {get_attr: [master_node_floating, floating_ip_address]} + + compute_nodes_ips: + value: {get_attr: [compute_nodes, compute_node_ip]} + + compute_node_names: + value: {get_attr: [compute_nodes, compute_node_name]} + + compute_node_external: + value: {get_attr: [compute_nodes, compute_node_external_ip]} + + compute_node_show: + value: {get_attr: [compute_nodes, compute_node_show]} diff --git a/heat_templates/compute_node.yaml b/heat_templates/juno/compute_node.yaml similarity index 85% rename from heat_templates/compute_node.yaml rename to heat_templates/juno/compute_node.yaml index 1da90dd..fdee50f 100644 --- a/heat_templates/compute_node.yaml +++ b/heat_templates/juno/compute_node.yaml @@ -1,7 +1,7 @@ heat_template_version: 2014-10-16 description: > - HOT template to deploy one compute node into an existing neutron tenant network and + HOT template to deploy one compute node into an xisting neutron tenant network and assign floating IP address to the server so they are routable from the public network. @@ -72,18 +72,27 @@ resources: yum -y remove NetworkManager chkconfig network on - cat > /etc/yum.repos.d/slurm.repo << EOF - [slurm] - name=slurm - baseurl=http://192.168.33.200/install/post/otherpkgs/el7/slurm + cat > /etc/yum.repos.d/torque.repo << EOF + [torque] + name=torque + baseurl=http://192.168.33.200/install/post/otherpkgs/el7/torque enabled=1 gpgcheck=0 EOF - yum -y install slurm slurm-munge + yum -y install torque-client - chkconfig munge on - chkconfig slurm on + chkconfig pbs_mom on + + echo $MASTER_NODE_IP > /var/spool/torque/server_name + + cat > /var/spool/torque/mom_priv/config << EOF + $logevent 0x1ff + + $pbsserver $MASTER_NODE_IP + EOF + + service pbs_mom start myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) myip_last_octet=${myip##*.} @@ -134,6 +143,9 @@ resources: protocol: icmp outputs: + compute_node_name: + description: The name of the compute node + value: { get_attr: [ compute_node, name ] } compute_node_ip: description: IP address of compute node in private network value: { get_attr: [ compute_node_eth0, fixed_ips, 0, ip_address ] } diff --git a/heat_templates/hpc.yaml b/heat_templates/juno/hpc.yaml similarity index 76% rename from heat_templates/hpc.yaml rename to heat_templates/juno/hpc.yaml index fd0897e..0c5335b 100644 --- a/heat_templates/hpc.yaml +++ b/heat_templates/juno/hpc.yaml @@ -1,9 +1,9 @@ heat_template_version: 2014-10-16 description: > - This template will boot a HPC cluster with one or more compute - nodes (as specified by the number_of_compute_nodes parameter, which - defaults to "10"). + This template will boot a Kubernetes cluster with one or more + minions (as specified by the number_of_minions parameter, which + defaults to "2"). parameters: @@ -29,19 +29,16 @@ parameters: type: string default: m1.small description: flavor to use when booting the server - constraints: - - allowed_values: [m1.tiny, m1.small, m1.large] - description: Value must be one of 'm1.tiny', 'm1.small' or 'm1.large' dns_nameserver: type: string - default: 8.8.8.8 description: address of a dns nameserver reachable in your environment + default: 8.8.8.8 number_of_compute_nodes: type: string - default: 10 description: how many compute nodes to spawn + default: 10 resources: @@ -120,7 +117,7 @@ resources: ###################################################################### # - # master_node server. this sets up a Master Node + # databases server. this sets up a MySQL server # master_node: type: "OS::Nova::Server" @@ -142,21 +139,48 @@ resources: yum -y upgrade - cat > /etc/yum.repos.d/slurm.repo << EOF - [slurm] - name=slurm - baseurl=http://192.168.33.200/install/post/otherpkgs/el7/slurm + cat > /etc/yum.repos.d/torque.repo << EOF + [torque] + name=torque + baseurl=http://192.168.33.200/install/post/otherpkgs/el7/torque enabled=1 gpgcheck=0 EOF - yum -y install slurm slurm-slurmdbd slurm-munge + yum -y install torque-server torque-scheduler - dd if=/dev/urandom bs=1 count=1024 /etc/munge.key - chmod 400 /etc/munge.key + chkconfig pbs_server on + chkconfig pbs_scheduler on - service munge restart + myip=$(ip addr show eth0 | awk '$1 == "inet" {print $2}' | cut -f1 -d/) + echo $myip > /var/spool/torque/server_name + rm -rf /var/spool/torque/server_priv/nodes + + for node in `echo $COMP_NODE_NAMES` + do + echo $node >> /var/spool/torque/server_priv/nodes + done + + # Parse the 2 variables to create /etc/hosts file + array1=(${COMP_NODE_ADDRESSES// / }) + array2=(${COMP_NODE_NAMES// / }) + + length=${#array1[@]} + + for ((i=0;i<=$length;i++)); do + echo -e "${array1[$i]} ${array2[$i]}" + done >> /etc/hosts + + # Start the torque services + service pbs_server start + service pbs_scheduler start + + qmgr -c "c q testq" + qmgr -c "s q testq queue_type=e" + qmgr -c "s q testq enabled=t" + qmgr -c "s q testq started=t" + qmgr -c "s s scheduling=true" cat > /tmp/wait-data << EOF { @@ -168,7 +192,8 @@ resources: EOF curl -T /tmp/wait-data '$WAIT_HANDLE' params: - "$COMP_NODE_ADDRESSES": {list_join: [",", {get_attr: [compute_nodes, compute_node_ip]}]} + "$COMP_NODE_ADDRESSES": {list_join: [" ", {get_attr: [compute_nodes, compute_node_ip]}]} + "$COMP_NODE_NAMES": {list_join: [" ", {get_attr: [compute_nodes, name]}]} "$WAIT_HANDLE": get_resource: master_wait_handle networks: @@ -197,10 +222,6 @@ resources: port_id: get_resource: master_node_eth0 - ###################################################################### - # - # compute_node server. this sets up the Compute Nodes - # compute_nodes: type: "OS::Heat::ResourceGroup" depends_on: @@ -227,5 +248,8 @@ outputs: compute_nodes: value: {get_attr: [compute_nodes, compute_node_ip]} + compute_names: + value: {get_attr: [compute_nodes, name]} + compute_node_external: value: {get_attr: [compute_nodes, compute_node_external_ip]} diff --git a/scripts/gre-packstack.sh b/scripts/gre-packstack.sh index 6c83f1b..9f56e61 100644 --- a/scripts/gre-packstack.sh +++ b/scripts/gre-packstack.sh @@ -6,6 +6,7 @@ cat > /tmp/sed.script << EOF s/\(CONFIG_KEYSTONE_ADMIN_PW=\).*/\1openstack/g s/\(CONFIG_HEAT_INSTALL=\).*/\1y/g s/\(CONFIG_NTP_SERVERS=\).*/\110.0.0.251/g +s/\(CONFIG_HEAT_CFN_INSTALL=\).*/\1y/g s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.1,10.0.0.2,10.0.0.3/g diff --git a/scripts/vxlan-packstack.sh b/scripts/vxlan-packstack.sh index 8ae9191..15155a5 100644 --- a/scripts/vxlan-packstack.sh +++ b/scripts/vxlan-packstack.sh @@ -6,6 +6,7 @@ cat > /tmp/sed.script << EOF s/\(CONFIG_KEYSTONE_ADMIN_PW=\).*/\1openstack/g s/\(CONFIG_HEAT_INSTALL=\).*/\1y/g s/\(CONFIG_NTP_SERVERS=\).*/\110.0.0.251/g +s/\(CONFIG_HEAT_CFN_INSTALL=\).*/\1y/g s/\(CONFIG_COMPUTE_HOSTS=\).*/\110.0.0.1,10.0.0.2,10.0.0.3/g