From 20d03919fb1741223de37e67f9af363d3ca85f76 Mon Sep 17 00:00:00 2001 From: Feilong Wang Date: Mon, 25 Feb 2019 23:56:59 +1300 Subject: [PATCH] Return instance ID of worker node Return the nova instance UUID of worker nodes in kubeminion templates. We will be able to remove resources from the ResourceGroups based on nova instance uuid. Backstory: In heat a ResourceGroup creates a stack of depth 2. ResourceGroups support removal policies to declare which resources must be removed. This can be done by passing the index of the resource or the stack_id of the nested stack. If a stack update call receives a list of indices (eg [0, 5, 3]) or nested stack uuid (eg [uuidA, uuidB]), it will remove the corresponding nested stacks. In magnum's heat templates, a nested stack logically represents a nova compute instance which is a cluster node. Using composition in heat, we can change the way a resources group references the nested stacks. This proposes to use the nova instance uuid as 'OS::stack_id'. With this change, an external consumer of the stack (the cluster autoscaler or an actual user) can remove resources from the ResourceGroup using the nova instance uuid or resource index. Without this change, a user or system (which typically knows the name, server uuid or ip) would have to find in which nested stack a kubernetes node belongs too. Resulting multiple call to heat. The end result of this patch can be verified like this: nested_stack_id=$(openstack stack resource show kube_minions -c physical_resource_id -f value) openstack stack show "${nested_stack_id}" Task: 29664 Story: 2005054 Change-Id: I6d776f62d640c72b3228460392b92df94fe56fe6 --- .../k8s_coreos_v1/templates/kubeminion.yaml | 15 +++++++++++++-- .../templates/kubeminion.yaml | 15 +++++++++++++-- .../templates/kubeminion.yaml | 15 +++++++++++++-- ...-server-id-in-kubeminion-cb33f5141e0b7fa9.yaml | 11 +++++++++++ 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/return-server-id-in-kubeminion-cb33f5141e0b7fa9.yaml diff --git a/magnum/drivers/k8s_coreos_v1/templates/kubeminion.yaml b/magnum/drivers/k8s_coreos_v1/templates/kubeminion.yaml index 2bbea9927f..b216fbeec6 100644 --- a/magnum/drivers/k8s_coreos_v1/templates/kubeminion.yaml +++ b/magnum/drivers/k8s_coreos_v1/templates/kubeminion.yaml @@ -524,7 +524,18 @@ outputs: description: > This is the "public" IP address of the Kubernetes minion node. + ###################################################################### + # + # NOTE(flwang): Returning the minion node server ID here so that + # consumer can send API request to Heat to remove a particular + # node with removal_policies. Otherwise, the consumer (e.g. AutoScaler) + # has to use index to do the remove which is confusing out of the + # OpenStack world. + # https://storyboard.openstack.org/#!/story/2005054 + # + ###################################################################### + OS::stack_id: - value: {get_param: "OS::stack_id"} + value: { get_resource: kube-minion } description: > - This is a id of the stack which creates from this template. + This is the Nova server id of the node. diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml index f62db5f55d..0dc834b8af 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml @@ -543,7 +543,18 @@ outputs: description: > This is the "public" IP address of the Kubernetes minion node. + ###################################################################### + # + # NOTE(flwang): Returning the minion node server ID here so that + # consumer can send API request to Heat to remove a particular + # node with removal_policies. Otherwise, the consumer (e.g. AutoScaler) + # has to use index to do the remove which is confusing out of the + # OpenStack world. + # https://storyboard.openstack.org/#!/story/2005054 + # + ###################################################################### + OS::stack_id: - value: {get_param: "OS::stack_id"} + value: { get_resource: kube-minion } description: > - This is a id of the stack which creates from this template. + This is the Nova server id of the node. diff --git a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion.yaml b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion.yaml index 143b1bab96..7e038b0fbc 100644 --- a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion.yaml +++ b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion.yaml @@ -108,7 +108,18 @@ outputs: description: > This is the "public" IP address of the Kubernetes minion node. + ###################################################################### + # + # NOTE(flwang): Returning the minion node server ID here so that + # consumer can send API request to Heat to remove a particular + # node with removal_policies. Otherwise, the consumer (e.g. AutoScaler) + # has to use index to do the remove which is confusing out of the + # OpenStack world. + # https://storyboard.openstack.org/#!/story/2005054 + # + ###################################################################### + OS::stack_id: - value: {get_param: "OS::stack_id"} + value: { get_resource: kube-minion } description: > - This is a id of the stack which creates from this template. + This is the Ironic server id of the node. diff --git a/releasenotes/notes/return-server-id-in-kubeminion-cb33f5141e0b7fa9.yaml b/releasenotes/notes/return-server-id-in-kubeminion-cb33f5141e0b7fa9.yaml new file mode 100644 index 0000000000..3a622ab657 --- /dev/null +++ b/releasenotes/notes/return-server-id-in-kubeminion-cb33f5141e0b7fa9.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - | + Return instance ID of workder node in k8s minion template so that + consumer can send API request to Heat to remove a particular + node with removal_policies. Otherwise, the consumer (e.g. AutoScaler) + has to use index to do the remove which is confusing out of the + OpenStack world. + https://storyboard.openstack.org/#!/story/2005054 + +