Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/lke_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Manage Linode LKE clusters.
|-----------|------|----------|------------------------------------------------------------------------------|
| `count` | <center>`int`</center> | <center>**Required**</center> | The number of nodes in the Node Pool. **(Updatable)** |
| `type` | <center>`str`</center> | <center>**Required**</center> | The Linode Type for all of the nodes in the Node Pool. |
| `label` | <center>`str`</center> | <center>Optional</center> | A unique label for this Node Pool. **(Updatable)** |
| [`autoscaler` (sub-options)](#autoscaler) | <center>`dict`</center> | <center>Optional</center> | When enabled, the number of nodes autoscales within the defined minimum and maximum values. **(Updatable)** |
| `labels` | <center>`dict`</center> | <center>Optional</center> | Key-value pairs added as labels to nodes in the node pool. Labels help classify your nodes and to easily select subsets of objects. **(Updatable)** |
| [`taints` (sub-options)](#taints) | <center>`list`</center> | <center>Optional</center> | Kubernetes taints to add to node pool nodes. Taints help control how pods are scheduled onto nodes, specifically allowing them to repel certain pods. **(Updatable)** |
Expand Down
1 change: 1 addition & 0 deletions docs/modules/lke_node_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Manage Linode LKE cluster node pools.
| `state` | <center>`str`</center> | <center>**Required**</center> | The desired state of the target. **(Choices: `present`, `absent`)** |
| [`autoscaler` (sub-options)](#autoscaler) | <center>`dict`</center> | <center>Optional</center> | When enabled, the number of nodes autoscales within the defined minimum and maximum values. **(Updatable)** |
| `count` | <center>`int`</center> | <center>Optional</center> | The number of nodes in the Node Pool. **(Updatable)** |
| `label` | <center>`str`</center> | <center>Optional</center> | A unique label for this Node Pool. **(Updatable)** |
| [`disks` (sub-options)](#disks) | <center>`list`</center> | <center>Optional</center> | This Node Pool’s custom disk layout. Each item in this array will create a new disk partition for each node in this Node Pool. |
| `type` | <center>`str`</center> | <center>Optional</center> | The Linode Type for all of the nodes in the Node Pool. Required if `state` == `present`. |
| `skip_polling` | <center>`bool`</center> | <center>Optional</center> | If true, the module will not wait for all nodes in the node pool to be ready. **(Default: `False`)** |
Expand Down
1 change: 1 addition & 0 deletions plugins/inventory/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
HAS_LINODE = False


# pylint: disable=too-many-ancestors
class InventoryModule(BaseInventoryPlugin, Constructable):
"""Linode instance inventory plugin"""

Expand Down
26 changes: 26 additions & 0 deletions plugins/modules/lke_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@
}

linode_lke_cluster_node_pool_spec = {
"label": SpecField(
type=FieldType.string,
editable=True,
description=["A unique label for this Node Pool."],
required=False,
),
"count": SpecField(
type=FieldType.integer,
editable=True,
Expand Down Expand Up @@ -567,6 +573,16 @@ def _update_cluster(self, cluster: LKECluster) -> None:
current_pool.labels = pool.get("labels")
current_pool.save()

if "label" in pool and current_pool.label != pool["label"]:
self.register_action(
"Updated label for Node Pool {}".format(
current_pool.id
)
)

current_pool.label = pool.get("label")
current_pool.save()

pools_handled[k] = True
should_keep[i] = True
break
Expand Down Expand Up @@ -635,6 +651,16 @@ def _update_cluster(self, cluster: LKECluster) -> None:
existing_pool.labels = pool["labels"]
should_update = True

if "label" in pool and existing_pool.label != pool["label"]:
self.register_action(
"Updated label for Node Pool {}".format(
existing_pool.id
)
)

existing_pool.label = pool["label"]
should_update = True

if should_update:
existing_pool.save()

Expand Down
12 changes: 12 additions & 0 deletions plugins/modules/lke_node_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
editable=True,
description=["The number of nodes in the Node Pool."],
),
"label": SpecField(
type=FieldType.string,
editable=True,
description=["A unique label for this Node Pool."],
required=False,
),
"disks": SpecField(
type=FieldType.list,
element_type=FieldType.dict,
Expand Down Expand Up @@ -319,6 +325,7 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool:
new_count = params.pop("count")
new_taints = params.pop("taints") if "taints" in params else None
new_labels = params.pop("labels") if "labels" in params else None
new_label = params.pop("label") if "label" in params else None
new_k8s_version = (
params.pop("k8s_version") if "k8s_version" in params else None
)
Expand Down Expand Up @@ -362,6 +369,11 @@ def _update_pool(self, pool: LKENodePool) -> LKENodePool:
pool.labels = new_labels
should_update = True

if new_label is not None and pool.label != new_label:
self.register_action("Updated label for Node Pool")
pool.label = new_label
should_update = True

if new_k8s_version is not None and pool.k8s_version != new_k8s_version:
self.register_action("Updated k8s version for Node Pool")
pool.k8s_version = new_k8s_version
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
linode-api4>=5.34.0
linode-api4>=5.35.0
polling==0.3.2
ansible-specdoc>=0.0.19
4 changes: 4 additions & 0 deletions tests/integration/targets/lke_cluster_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
effect: NoExecute
- type: g6-standard-4
count: 1
label: pool-with-autoscaler
autoscaler:
enabled: true
min: 1
Expand All @@ -55,6 +56,7 @@
- create_cluster.cluster.region == 'us-southeast'
- create_cluster.node_pools[0].type == 'g6-standard-1'
- create_cluster.node_pools[0].count == 3
- create_cluster.node_pools[1].label == 'pool-with-autoscaler'
- create_cluster.node_pools[0].labels['foo.example.com/test'] == 'bar'
- create_cluster.node_pools[0].labels['foo.example.com/test2'] == 'foo'
- create_cluster.node_pools[0].taints[0].key == 'foo.example.com/test2'
Expand All @@ -73,6 +75,7 @@
node_pools:
- type: g6-standard-1
count: 2
label: updated-pool-label
labels:
foo.example.com/update: updated
foo.example.com/test2: foo
Expand All @@ -97,6 +100,7 @@

- update_pools.node_pools[0].type == 'g6-standard-1'
- update_pools.node_pools[0].count == 2
- update_pools.node_pools[0].label == 'updated-pool-label'
- update_pools.node_pools[0].id == create_cluster.node_pools[0].id

- update_pools.node_pools[0].labels['foo.example.com/update'] == 'updated'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
tags: ['my-pool']
type: g6-standard-1
count: 2
label: new-pool-label
labels:
foo.example.com/test: bar
foo.example.com/test2: foo
Expand All @@ -58,6 +59,7 @@
assert:
that:
- new_pool.node_pool.count == 2
- new_pool.node_pool.label == 'new-pool-label'
- new_pool.node_pool.type == 'g6-standard-1'
- new_pool.node_pool.nodes[0].status == 'ready'
- new_pool.node_pool.nodes[1].status == 'ready'
Expand Down Expand Up @@ -86,6 +88,7 @@
type: g6-standard-1
count: 1
skip_polling: true
label: updated-pool-label
autoscaler:
enabled: true
min: 1
Expand All @@ -104,6 +107,7 @@
assert:
that:
- update_pool.node_pool.count == 1
- update_pool.node_pool.label == 'updated-pool-label'
- update_pool.node_pool.type == 'g6-standard-1'
- update_pool.node_pool.autoscaler.enabled
- update_pool.node_pool.autoscaler.min == 1
Expand Down