Modify k8s template to support removal policy

Add a parameter 'minions_to_remove' that lists resources to be
removed on stack update. The value will be passed to removal_policy
of the 'kube_minions' resource group.

Change-Id: I65a9473789742fdf8d05deaa229a6b8e4a9884e3
Partially-Implements: blueprint magnum-smart-bay-scale-down
changes/05/196505/6
Hongbin Lu 8 years ago
parent 8d9649bc1f
commit 2d153fc83d

@ -117,6 +117,9 @@ class OutputMapping(object):
self.heat_output = heat_output
def set_output(self, stack, bay):
if self.bay_attr is None:
return
for output in stack.outputs:
if output['output_key'] == self.heat_output:
setattr(bay, self.bay_attr, output['output_value'])
@ -320,6 +323,8 @@ class AtomicK8sTemplateDefinition(BaseTemplateDefinition):
self.add_output('kube_master',
bay_attr='api_address')
self.add_output('kube_minions',
bay_attr=None)
self.add_output('kube_minions_external',
bay_attr='node_addresses')

@ -94,6 +94,15 @@ parameters:
storage
default: 25
minions_to_remove:
type: comma_delimited_list
description: >
List of minions to be removed when doing an update. Individual minion may
be referenced several ways: (1) The resource name (e.g. ['1', '3']),
(2) The private IP address ['10.0.0.4', '10.0.0.6']. Note: the list should
be empty when doing an create.
default: []
resources:
master_wait_handle:
@ -328,6 +337,7 @@ resources:
- extrouter_inside
properties:
count: {get_param: number_of_minions}
removal_policies: [{resource_list: {get_param: minions_to_remove}}]
resource_def:
type: kubenode-coreos.yaml
properties:
@ -353,4 +363,3 @@ outputs:
kube_minions_external:
value: {get_attr: [kube_minions, kube_node_external_ip]}

@ -73,6 +73,15 @@ parameters:
constraints:
- allowed_values: ["true", "false"]
minions_to_remove:
type: comma_delimited_list
description: >
List of minions to be removed when doing an update. Individual minion may
be referenced several ways: (1) The resource name (e.g. ['1', '3']),
(2) The private IP address ['10.0.0.4', '10.0.0.6']. Note: the list should
be empty when doing an create.
default: []
resources:
######################################################################
@ -207,6 +216,7 @@ resources:
depends_on: kube_master
properties:
count: {get_param: number_of_minions}
removal_policies: [{resource_list: {get_param: minions_to_remove}}]
resource_def:
type: kubenode-fedora-ironic.yaml
properties:
@ -227,4 +237,4 @@ outputs:
value: {get_attr: [kube_minions, kube_node_ip]}
kube_minions_external:
value: {get_attr: [kube_minions, kube_node_external_ip]}
value: {get_attr: [kube_minions, kube_node_external_ip]}

@ -87,10 +87,19 @@ parameters:
wait_condition_timeout:
type: number
description : >
description: >
timeout for the Wait Conditions
default: 6000
minions_to_remove:
type: comma_delimited_list
description: >
List of minions to be removed when doing an update. Individual minion may
be referenced several ways: (1) The resource name (e.g. ['1', '3']),
(2) The private IP address ['10.0.0.4', '10.0.0.6']. Note: the list should
be empty when doing an create.
default: []
resources:
master_wait_handle:
@ -307,6 +316,7 @@ resources:
- master_wait_condition
properties:
count: {get_param: number_of_minions}
removal_policies: [{resource_list: {get_param: minions_to_remove}}]
resource_def:
type: kubeminion.yaml
properties:

@ -221,5 +221,9 @@ outputs:
kube_minion_ip:
value: {get_attr: [kube_minion_eth0, fixed_ips, 0, ip_address]}
kube_minion_external_ip:
value: {get_attr: [kube_minion_floating, floating_ip_address]}
OS::stack_id:
value: {get_attr: [kube_minion_eth0, fixed_ips, 0, ip_address]}

@ -249,3 +249,5 @@ outputs:
kube_node_external_ip:
value: {get_attr: [kube_node_floating, floating_ip_address]}
OS::stack_id:
value: {get_attr: [kube_node_eth0, fixed_ips, 0, ip_address]}

@ -173,3 +173,5 @@ outputs:
kube_node_external_ip:
value: {get_attr: [kube_node_floating, floating_ip_address]}
OS::stack_id:
value: {get_attr: [kube_node, networks, private, 0]}

@ -284,7 +284,10 @@ class TestBayConductorWithK8s(base.TestCase):
"output_key": "kube_minions_external"},
{"output_value": expected_api_address,
"description": "No description given",
"output_key": "kube_master"}
"output_key": "kube_master"},
{"output_value": ['any', 'output'],
"description": "No description given",
"output_key": "kube_minions"}
]
mock_stack = mock.MagicMock()
mock_stack.outputs = outputs

Loading…
Cancel
Save