From 4b439253e7b4486947d201714d4f52a4a7e0fc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Thu, 25 Jun 2015 10:08:52 +0200 Subject: Make all the OpenStack resources be managed by a Heat Stack --- .../openshift-cluster/files/heat_stack.yaml | 279 +++++++++++++++++++++ .../openshift-cluster/files/heat_stack.yml | 149 ----------- .../openshift-cluster/files/heat_stack_server.yaml | 123 +++++++++ 3 files changed, 402 insertions(+), 149 deletions(-) create mode 100644 playbooks/openstack/openshift-cluster/files/heat_stack.yaml delete mode 100644 playbooks/openstack/openshift-cluster/files/heat_stack.yml create mode 100644 playbooks/openstack/openshift-cluster/files/heat_stack_server.yaml (limited to 'playbooks/openstack/openshift-cluster/files') diff --git a/playbooks/openstack/openshift-cluster/files/heat_stack.yaml b/playbooks/openstack/openshift-cluster/files/heat_stack.yaml new file mode 100644 index 000000000..a15ec749c --- /dev/null +++ b/playbooks/openstack/openshift-cluster/files/heat_stack.yaml @@ -0,0 +1,279 @@ +heat_template_version: 2014-10-16 + +description: OpenShift cluster + +parameters: + + cluster_id: + type: string + label: Cluster ID + description: Identifier of the cluster + + num_masters: + type: number + label: Number of masters + description: Number of masters + + num_nodes: + type: number + label: Number of nodes + description: Number of nodes + + cidr: + type: string + label: CIDR + description: CIDR of the network of the cluster + + dns_nameservers: + type: comma_delimited_list + label: DNS nameservers list + description: List of DNS nameservers + + external_net: + type: string + label: External network + description: Name of the external network + default: external + + ssh_public_key: + type: string + label: SSH public key + description: SSH public key + hidden: true + + ssh_incoming: + type: string + label: Source of ssh connections + description: Source of legitimate ssh connections + default: 0.0.0.0/0 + + master_image: + type: string + label: Master image + description: Name of the image for the master servers + + node_image: + type: string + label: Node image + description: Name of the image for the node servers + + master_flavor: + type: string + label: Master flavor + description: Flavor of the master servers + + node_flavor: + type: string + label: Node flavor + description: Flavor of the node servers + +outputs: + + master_names: + description: Name of the masters + value: { get_attr: [ masters, name ] } + + master_ips: + description: IPs of the masters + value: { get_attr: [ masters, private_ip ] } + + master_floating_ips: + description: Floating IPs of the masters + value: { get_attr: [ masters, floating_ip ] } + + node_names: + description: Name of the nodes + value: { get_attr: [ nodes, name ] } + + node_ips: + description: IPs of the nodes + value: { get_attr: [ nodes, private_ip ] } + + node_floating_ips: + description: Floating IPs of the nodes + value: { get_attr: [ nodes, floating_ip ] } + +resources: + + net: + type: OS::Neutron::Net + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-net + params: + cluster_id: { get_param: cluster_id } + + subnet: + type: OS::Neutron::Subnet + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-subnet + params: + cluster_id: { get_param: cluster_id } + network: { get_resource: net } + cidr: { get_param: cidr } + dns_nameservers: { get_param: dns_nameservers } + + router: + type: OS::Neutron::Router + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-router + params: + cluster_id: { get_param: cluster_id } + external_gateway_info: + network: { get_param: external_net } + + interface: + type: OS::Neutron::RouterInterface + properties: + router_id: { get_resource: router } + subnet_id: { get_resource: subnet } + + keypair: + type: OS::Nova::KeyPair + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-keypair + params: + cluster_id: { get_param: cluster_id } + public_key: { get_param: ssh_public_key } + + master-secgrp: + type: OS::Neutron::SecurityGroup + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-master-secgrp + params: + cluster_id: { get_param: cluster_id } + description: + str_replace: + template: Security group for cluster_id OpenShift cluster master + params: + cluster_id: { get_param: cluster_id } + rules: + - direction: ingress + protocol: tcp + port_range_min: 22 + port_range_max: 22 + remote_ip_prefix: { get_param: ssh_incoming } + - direction: ingress + protocol: tcp + port_range_min: 4001 + port_range_max: 4001 + - direction: ingress + protocol: tcp + port_range_min: 8443 + port_range_max: 8443 + - direction: ingress + protocol: tcp + port_range_min: 53 + port_range_max: 53 + - direction: ingress + protocol: udp + port_range_min: 53 + port_range_max: 53 + - direction: ingress + protocol: tcp + port_range_min: 24224 + port_range_max: 24224 + - direction: ingress + protocol: udp + port_range_min: 24224 + port_range_max: 24224 + + node-secgrp: + type: OS::Neutron::SecurityGroup + properties: + name: + str_replace: + template: openshift-ansible-cluster_id-node-secgrp + params: + cluster_id: { get_param: cluster_id } + description: + str_replace: + template: Security group for cluster_id OpenShift cluster nodes + params: + cluster_id: { get_param: cluster_id } + rules: + - direction: ingress + protocol: tcp + port_range_min: 22 + port_range_max: 22 + remote_ip_prefix: { get_param: ssh_incoming } + - direction: ingress + protocol: udp + port_range_min: 4789 + port_range_max: 4789 + remote_mode: remote_group_id + - direction: ingress + protocol: tcp + port_range_min: 10250 + port_range_max: 10250 + remote_mode: remote_group_id + remote_group_id: { get_resource: master-secgrp } + + masters: + type: OS::Heat::ResourceGroup + properties: + count: { get_param: num_masters } + resource_def: + type: heat_stack_server.yaml + properties: + name: + str_replace: + template: cluster_id-k8s_type-%index% + params: + cluster_id: { get_param: cluster_id } + k8s_type: master + cluster_id: { get_param: cluster_id } + type: master + image: { get_param: master_image } + flavor: { get_param: master_flavor } + key_name: { get_resource: keypair } + net: { get_resource: net } + subnet: { get_resource: subnet } + secgrp: + - { get_resource: master-secgrp } + floating_network: { get_param: external_net } + net_name: + str_replace: + template: openshift-ansible-cluster_id-net + params: + cluster_id: { get_param: cluster_id } + depends_on: interface + + nodes: + type: OS::Heat::ResourceGroup + properties: + count: { get_param: num_nodes } + resource_def: + type: heat_stack_server.yaml + properties: + name: + str_replace: + template: cluster_id-k8s_type-%index% + params: + cluster_id: { get_param: cluster_id } + k8s_type: node + cluster_id: { get_param: cluster_id } + type: node + image: { get_param: node_image } + flavor: { get_param: node_flavor } + key_name: { get_resource: keypair } + net: { get_resource: net } + subnet: { get_resource: subnet } + secgrp: + - { get_resource: node-secgrp } + floating_network: { get_param: external_net } + net_name: + str_replace: + template: openshift-ansible-cluster_id-net + params: + cluster_id: { get_param: cluster_id } + depends_on: interface diff --git a/playbooks/openstack/openshift-cluster/files/heat_stack.yml b/playbooks/openstack/openshift-cluster/files/heat_stack.yml deleted file mode 100644 index c5f95d87d..000000000 --- a/playbooks/openstack/openshift-cluster/files/heat_stack.yml +++ /dev/null @@ -1,149 +0,0 @@ -heat_template_version: 2014-10-16 - -description: OpenShift cluster - -parameters: - cluster-id: - type: string - label: Cluster ID - description: Identifier of the cluster - - network-prefix: - type: string - label: Network prefix - description: Prefix of the network objects - - cidr: - type: string - label: CIDR - description: CIDR of the network of the cluster - - dns-nameservers: - type: comma_delimited_list - label: DNS nameservers list - description: List of DNS nameservers - - external-net: - type: string - label: External network - description: Name of the external network - default: external - - ssh-incoming: - type: string - label: Source of ssh connections - description: Source of legitimate ssh connections - -resources: - net: - type: OS::Neutron::Net - properties: - name: - str_replace: - template: network-prefix-net - params: - network-prefix: { get_param: network-prefix } - - subnet: - type: OS::Neutron::Subnet - properties: - name: - str_replace: - template: network-prefix-subnet - params: - network-prefix: { get_param: network-prefix } - network: { get_resource: net } - cidr: { get_param: cidr } - dns_nameservers: { get_param: dns-nameservers } - - router: - type: OS::Neutron::Router - properties: - name: - str_replace: - template: network-prefix-router - params: - network-prefix: { get_param: network-prefix } - external_gateway_info: - network: { get_param: external-net } - - interface: - type: OS::Neutron::RouterInterface - properties: - router_id: { get_resource: router } - subnet_id: { get_resource: subnet } - - node-secgrp: - type: OS::Neutron::SecurityGroup - properties: - name: - str_replace: - template: network-prefix-node-secgrp - params: - network-prefix: { get_param: network-prefix } - description: - str_replace: - template: Security group for cluster-id OpenShift cluster nodes - params: - cluster-id: { get_param: cluster-id } - rules: - - direction: ingress - protocol: tcp - port_range_min: 22 - port_range_max: 22 - remote_ip_prefix: { get_param: ssh-incoming } - - direction: ingress - protocol: udp - port_range_min: 4789 - port_range_max: 4789 - remote_mode: remote_group_id - - direction: ingress - protocol: tcp - port_range_min: 10250 - port_range_max: 10250 - remote_mode: remote_group_id - remote_group_id: { get_resource: master-secgrp } - - master-secgrp: - type: OS::Neutron::SecurityGroup - properties: - name: - str_replace: - template: network-prefix-master-secgrp - params: - network-prefix: { get_param: network-prefix } - description: - str_replace: - template: Security group for cluster-id OpenShift cluster master - params: - cluster-id: { get_param: cluster-id } - rules: - - direction: ingress - protocol: tcp - port_range_min: 22 - port_range_max: 22 - remote_ip_prefix: { get_param: ssh-incoming } - - direction: ingress - protocol: tcp - port_range_min: 4001 - port_range_max: 4001 - - direction: ingress - protocol: tcp - port_range_min: 8443 - port_range_max: 8443 - - direction: ingress - protocol: tcp - port_range_min: 53 - port_range_max: 53 - - direction: ingress - protocol: udp - port_range_min: 53 - port_range_max: 53 - - direction: ingress - protocol: tcp - port_range_min: 24224 - port_range_max: 24224 - - direction: ingress - protocol: udp - port_range_min: 24224 - port_range_max: 24224 diff --git a/playbooks/openstack/openshift-cluster/files/heat_stack_server.yaml b/playbooks/openstack/openshift-cluster/files/heat_stack_server.yaml new file mode 100644 index 000000000..55f64211a --- /dev/null +++ b/playbooks/openstack/openshift-cluster/files/heat_stack_server.yaml @@ -0,0 +1,123 @@ +heat_template_version: 2014-10-16 + +description: OpenShift cluster server + +parameters: + + name: + type: string + label: Name + description: Name + + cluster_id: + type: string + label: Cluster ID + description: Identifier of the cluster + + type: + type: string + label: Type + description: Type master or node + + key_name: + type: string + label: Key name + description: Key name of keypair + + image: + type: string + label: Image + description: Name of the image + + flavor: + type: string + label: Flavor + description: Name of the flavor + + net: + type: string + label: Net ID + description: Net resource + + net_name: + type: string + label: Net name + description: Net name + + subnet: + type: string + label: Subnet ID + description: Subnet resource + + secgrp: + type: comma_delimited_list + label: Security groups + description: Security group resources + + floating_network: + type: string + label: Floating network + description: Network to allocate floating IP from + +outputs: + + name: + description: Name of the server + value: { get_attr: [ server, name ] } + + private_ip: + description: Private IP of the server + value: + get_attr: + - server + - addresses + - { get_param: net_name } + - 0 + - addr + + floating_ip: + description: Floating IP of the server + value: + get_attr: + - server + - addresses + - { get_param: net_name } + - 1 + - addr + +resources: + + server: + type: OS::Nova::Server + properties: + name: { get_param: name } + key_name: { get_param: key_name } + image: { get_param: image } + flavor: { get_param: flavor } + networks: + - port: { get_resource: port } + user_data: { get_file: user-data } + user_data_format: RAW + metadata: + env: { get_param: cluster_id } + host-type: { get_param: type } + env-host-type: + str_template: + template: cluster_id-openshift-type + params: + cluster_id: { get_param: cluster_id } + type: { get_param: type } + + port: + type: OS::Neutron::Port + properties: + network: { get_param: net } + fixed_ips: + - subnet: { get_param: subnet } + security_groups: { get_param: secgrp } + + floating-ip: + type: OS::Neutron::FloatingIP + properties: + floating_network: { get_param: floating_network } + port_id: { get_resource: port } -- cgit v1.2.3