Consolidate heat network resources

Currently for each driver has following code
  1) Create a fixed Network.
  2) Create a fixed subnet in the network created at step 1.
  3) Create a router
  4) Attach subnet(created at step2) to router(created at step 3)

A new resource is created for above tasks in network.yaml file.
New resource does the above tasks and output the fixed network ID
and fixed subnet id, which is used by other parts of the heat
template.

Change-Id: Ib347ce5c54c6566300a43e05b277bf80351a2256
Closes-Bug: #1606912
This commit is contained in:
Rajiv Kumar 2016-07-27 19:35:41 +05:30 committed by Mathieu Velten
parent 5ede934aaf
commit 10e85ee6ce
5 changed files with 113 additions and 128 deletions

View File

@ -0,0 +1,60 @@
heat_template_version: 2014-10-16
description: >
Creates network resources for the cluster. allocate a network and
router for our server.
parameters:
fixed_network_cidr:
type: string
description: network range for fixed ip network
fixed_network_name:
type: string
description: fixed network name
default: ""
dns_nameserver:
type: string
description: address of a dns nameserver reachable in your environment
external_network:
type: string
description: uuid/name of a network to use for floating ip addresses
resources:
fixed_network:
type: OS::Neutron::Net
properties:
name: {get_param: fixed_network_name}
fixed_subnet:
type: OS::Neutron::Subnet
properties:
cidr: {get_param: fixed_network_cidr}
network: {get_resource: fixed_network}
dns_nameservers:
- {get_param: dns_nameserver}
extrouter:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: {get_param: external_network}
extrouter_inside:
type: OS::Neutron::RouterInterface
properties:
router_id: {get_resource: extrouter}
subnet: {get_resource: fixed_subnet}
outputs:
fixed_network:
description: >
Created fixed network ID
value: {get_resource: fixed_network}
fixed_subnet:
description: >
Created fixed subnet ID
value: {get_resource: fixed_subnet}

View File

@ -209,35 +209,18 @@ resources:
# address lookup in Kubernetes to work properly # address lookup in Kubernetes to work properly
# #
fixed_network: network:
type: OS::Neutron::Net type: ../../common/templates/network.yaml
properties: properties:
name: private fixed_network_cidr: {get_param: fixed_network_cidr}
dns_nameserver: {get_param: dns_nameserver}
fixed_subnet: external_network: {get_param: external_network}
type: OS::Neutron::Subnet fixed_network_name: private
properties:
cidr: {get_param: fixed_network_cidr}
network: {get_resource: fixed_network}
dns_nameservers:
- {get_param: dns_nameserver}
extrouter:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: {get_param: external_network}
extrouter_inside:
type: OS::Neutron::RouterInterface
properties:
router_id: {get_resource: extrouter}
subnet: {get_resource: fixed_subnet}
api_lb: api_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: {get_param: loadbalancing_protocol} protocol: {get_param: loadbalancing_protocol}
port: {get_param: kubernetes_port} port: {get_param: kubernetes_port}
@ -245,7 +228,7 @@ resources:
etcd_lb: etcd_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: HTTP protocol: HTTP
port: 2379 port: 2379
@ -329,7 +312,7 @@ resources:
kube_masters: kube_masters:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_masters} count: {get_param: number_of_masters}
resource_def: resource_def:
@ -346,8 +329,8 @@ resources:
flannel_network_subnetlen: {get_param: flannel_network_subnetlen} flannel_network_subnetlen: {get_param: flannel_network_subnetlen}
flannel_backend: {get_param: flannel_backend} flannel_backend: {get_param: flannel_backend}
portal_network_cidr: {get_param: portal_network_cidr} portal_network_cidr: {get_param: portal_network_cidr}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
discovery_url: {get_param: discovery_url} discovery_url: {get_param: discovery_url}
network_driver: {get_param: network_driver} network_driver: {get_param: network_driver}
kubernetes_port: {get_param: kubernetes_port} kubernetes_port: {get_param: kubernetes_port}
@ -376,7 +359,7 @@ resources:
kube_minions: kube_minions:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
- kube_masters - kube_masters
properties: properties:
count: {get_param: number_of_minions} count: {get_param: number_of_minions}
@ -387,8 +370,8 @@ resources:
ssh_key_name: {get_param: ssh_key_name} ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image} server_image: {get_param: server_image}
minion_flavor: {get_param: minion_flavor} minion_flavor: {get_param: minion_flavor}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
flannel_network_cidr: {get_param: flannel_network_cidr} flannel_network_cidr: {get_param: flannel_network_cidr}
kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]} kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]}
etcd_server_ip: {get_attr: [etcd_address_lb_switch, private_ip]} etcd_server_ip: {get_attr: [etcd_address_lb_switch, private_ip]}

View File

@ -273,35 +273,18 @@ resources:
# address lookup in Kubernetes to work properly # address lookup in Kubernetes to work properly
# #
fixed_network: network:
type: OS::Neutron::Net type: ../../common/templates/network.yaml
properties: properties:
name: private fixed_network_cidr: {get_param: fixed_network_cidr}
dns_nameserver: {get_param: dns_nameserver}
fixed_subnet: external_network: {get_param: external_network}
type: OS::Neutron::Subnet fixed_network_name: private
properties:
cidr: {get_param: fixed_network_cidr}
network: {get_resource: fixed_network}
dns_nameservers:
- {get_param: dns_nameserver}
extrouter:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: {get_param: external_network}
extrouter_inside:
type: OS::Neutron::RouterInterface
properties:
router_id: {get_resource: extrouter}
subnet: {get_resource: fixed_subnet}
api_lb: api_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: {get_param: loadbalancing_protocol} protocol: {get_param: loadbalancing_protocol}
port: {get_param: kubernetes_port} port: {get_param: kubernetes_port}
@ -309,7 +292,7 @@ resources:
etcd_lb: etcd_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: HTTP protocol: HTTP
port: 2379 port: 2379
@ -396,7 +379,7 @@ resources:
kube_masters: kube_masters:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_masters} count: {get_param: number_of_masters}
resource_def: resource_def:
@ -420,8 +403,8 @@ resources:
discovery_url: {get_param: discovery_url} discovery_url: {get_param: discovery_url}
cluster_uuid: {get_param: cluster_uuid} cluster_uuid: {get_param: cluster_uuid}
magnum_url: {get_param: magnum_url} magnum_url: {get_param: magnum_url}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
api_pool_id: {get_attr: [api_lb, pool_id]} api_pool_id: {get_attr: [api_lb, pool_id]}
etcd_pool_id: {get_attr: [etcd_lb, pool_id]} etcd_pool_id: {get_attr: [etcd_lb, pool_id]}
username: {get_param: username} username: {get_param: username}
@ -449,7 +432,7 @@ resources:
kube_minions: kube_minions:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_minions} count: {get_param: number_of_minions}
removal_policies: [{resource_list: {get_param: minions_to_remove}}] removal_policies: [{resource_list: {get_param: minions_to_remove}}]
@ -459,8 +442,8 @@ resources:
ssh_key_name: {get_param: ssh_key_name} ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image} server_image: {get_param: server_image}
minion_flavor: {get_param: minion_flavor} minion_flavor: {get_param: minion_flavor}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
network_driver: {get_param: network_driver} network_driver: {get_param: network_driver}
flannel_network_cidr: {get_param: flannel_network_cidr} flannel_network_cidr: {get_param: flannel_network_cidr}
kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]} kube_master_ip: {get_attr: [api_address_lb_switch, private_ip]}

View File

@ -204,33 +204,17 @@ resources:
# network resources. allocate a network and router for our server. # network resources. allocate a network and router for our server.
# #
fixed_network: network:
type: OS::Neutron::Net type: ../../common/templates/network.yaml
fixed_subnet:
type: OS::Neutron::Subnet
properties: properties:
cidr: {get_param: fixed_network_cidr} fixed_network_cidr: {get_param: fixed_network_cidr}
network: {get_resource: fixed_network} dns_nameserver: {get_param: dns_nameserver}
dns_nameservers: external_network: {get_param: external_network}
- {get_param: dns_nameserver}
extrouter:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: {get_param: external_network}
extrouter_inside:
type: OS::Neutron::RouterInterface
properties:
router_id: {get_resource: extrouter}
subnet: {get_resource: fixed_subnet}
api_lb: api_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: HTTP protocol: HTTP
port: 8080 port: 8080
@ -373,7 +357,7 @@ resources:
mesos_masters: mesos_masters:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_masters} count: {get_param: number_of_masters}
resource_def: resource_def:
@ -383,8 +367,8 @@ resources:
server_image: {get_param: server_image} server_image: {get_param: server_image}
master_flavor: {get_param: master_flavor} master_flavor: {get_param: master_flavor}
external_network: {get_param: external_network} external_network: {get_param: external_network}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
secgroup_mesos_id: {get_resource: secgroup_master} secgroup_mesos_id: {get_resource: secgroup_master}
api_pool_id: {get_attr: [api_lb, pool_id]} api_pool_id: {get_attr: [api_lb, pool_id]}
@ -397,7 +381,7 @@ resources:
mesos_slaves: mesos_slaves:
type: OS::Heat::ResourceGroup type: OS::Heat::ResourceGroup
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_slaves} count: {get_param: number_of_slaves}
removal_policies: [{resource_list: {get_param: slaves_to_remove}}] removal_policies: [{resource_list: {get_param: slaves_to_remove}}]
@ -407,8 +391,8 @@ resources:
ssh_key_name: {get_param: ssh_key_name} ssh_key_name: {get_param: ssh_key_name}
server_image: {get_param: server_image} server_image: {get_param: server_image}
slave_flavor: {get_param: slave_flavor} slave_flavor: {get_param: slave_flavor}
fixed_network: {get_resource: fixed_network} fixed_network: {get_attr: [network, fixed_network]}
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
mesos_masters_ips: {list_join: [' ', {get_attr: [mesos_masters, mesos_master_ip]}]} mesos_masters_ips: {list_join: [' ', {get_attr: [mesos_masters, mesos_master_ip]}]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
wait_condition_timeout: {get_param: wait_condition_timeout} wait_condition_timeout: {get_param: wait_condition_timeout}

View File

@ -243,42 +243,17 @@ resources:
# etc, as parameters), but I wanted to minmize the amount of # etc, as parameters), but I wanted to minmize the amount of
# configuration necessary to make this go. # configuration necessary to make this go.
fixed_network: network:
type: "OS::Neutron::Net" type: ../../common/templates/network.yaml
# This is the subnet on which we will deploy our server.
fixed_subnet:
type: "OS::Neutron::Subnet"
properties: properties:
cidr: {get_param: fixed_network_cidr} fixed_network_cidr: {get_param: fixed_network_cidr}
network_id: dns_nameserver: {get_param: dns_nameserver}
get_resource: fixed_network external_network: {get_param: external_network}
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: external_network
# 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
api_lb: api_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: {get_param: loadbalancing_protocol} protocol: {get_param: loadbalancing_protocol}
port: {get_param: swarm_port} port: {get_param: swarm_port}
@ -286,7 +261,7 @@ resources:
etcd_lb: etcd_lb:
type: ../../common/templates/lb.yaml type: ../../common/templates/lb.yaml
properties: properties:
fixed_subnet: {get_resource: fixed_subnet} fixed_subnet: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
protocol: HTTP protocol: HTTP
port: 2379 port: 2379
@ -335,7 +310,7 @@ resources:
swarm_masters: swarm_masters:
type: "OS::Heat::ResourceGroup" type: "OS::Heat::ResourceGroup"
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_masters} count: {get_param: number_of_masters}
resource_def: resource_def:
@ -346,8 +321,8 @@ resources:
server_flavor: {get_param: master_flavor} server_flavor: {get_param: master_flavor}
docker_volume_size: {get_param: docker_volume_size} docker_volume_size: {get_param: docker_volume_size}
docker_storage_driver: {get_param: docker_storage_driver} docker_storage_driver: {get_param: docker_storage_driver}
fixed_network_id: {get_resource: fixed_network} fixed_network_id: {get_attr: [network, fixed_network]}
fixed_subnet_id: {get_resource: fixed_subnet} fixed_subnet_id: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
discovery_url: {get_param: discovery_url} discovery_url: {get_param: discovery_url}
http_proxy: {get_param: http_proxy} http_proxy: {get_param: http_proxy}
@ -379,7 +354,7 @@ resources:
swarm_nodes: swarm_nodes:
type: "OS::Heat::ResourceGroup" type: "OS::Heat::ResourceGroup"
depends_on: depends_on:
- extrouter_inside - network
properties: properties:
count: {get_param: number_of_nodes} count: {get_param: number_of_nodes}
resource_def: resource_def:
@ -390,8 +365,8 @@ resources:
server_flavor: {get_param: node_flavor} server_flavor: {get_param: node_flavor}
docker_volume_size: {get_param: docker_volume_size} docker_volume_size: {get_param: docker_volume_size}
docker_storage_driver: {get_param: docker_storage_driver} docker_storage_driver: {get_param: docker_storage_driver}
fixed_network_id: {get_resource: fixed_network} fixed_network_id: {get_attr: [network, fixed_network]}
fixed_subnet_id: {get_resource: fixed_subnet} fixed_subnet_id: {get_attr: [network, fixed_subnet]}
external_network: {get_param: external_network} external_network: {get_param: external_network}
http_proxy: {get_param: http_proxy} http_proxy: {get_param: http_proxy}
https_proxy: {get_param: https_proxy} https_proxy: {get_param: https_proxy}