14
14
Region ,
15
15
Type ,
16
16
)
17
+ from linode_api4 .objects .base import _flatten_request_body_recursive
17
18
from linode_api4 .util import drop_null_keys
18
19
19
20
@@ -49,6 +50,26 @@ class KubeVersion(Base):
49
50
}
50
51
51
52
53
+ class TieredKubeVersion (DerivedBase ):
54
+ """
55
+ A TieredKubeVersion is a version of Kubernetes that is specific to a certain LKE tier.
56
+
57
+ NOTE: LKE tiers may not currently be available to all users.
58
+
59
+ API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lke-version
60
+ """
61
+
62
+ api_endpoint = "/lke/tiers/{tier}/versions/{id}"
63
+ parent_id_name = "tier"
64
+ id_attribute = "id"
65
+ derived_url_path = "versions"
66
+
67
+ properties = {
68
+ "id" : Property (identifier = True ),
69
+ "tier" : Property (identifier = True ),
70
+ }
71
+
72
+
52
73
@dataclass
53
74
class LKENodePoolTaint (JSONObject ):
54
75
"""
@@ -154,6 +175,8 @@ class LKENodePool(DerivedBase):
154
175
An LKE Node Pool describes a pool of Linode Instances that exist within an
155
176
LKE Cluster.
156
177
178
+ NOTE: The k8s_version and update_strategy fields are only available for LKE Enterprise clusters.
179
+
157
180
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lke-node-pool
158
181
"""
159
182
@@ -175,6 +198,12 @@ class LKENodePool(DerivedBase):
175
198
"tags" : Property (mutable = True , unordered = True ),
176
199
"labels" : Property (mutable = True ),
177
200
"taints" : Property (mutable = True ),
201
+ # Enterprise-specific properties
202
+ # Ideally we would use slug_relationship=TieredKubeVersion here, but
203
+ # it isn't possible without an extra request because the tier is not
204
+ # directly exposed in the node pool response.
205
+ "k8s_version" : Property (mutable = True ),
206
+ "update_strategy" : Property (mutable = True ),
178
207
}
179
208
180
209
def _parse_raw_node (
@@ -255,6 +284,7 @@ class LKECluster(Base):
255
284
"pools" : Property (derived_class = LKENodePool ),
256
285
"control_plane" : Property (mutable = True ),
257
286
"apl_enabled" : Property (),
287
+ "tier" : Property (),
258
288
}
259
289
260
290
def invalidate (self ):
@@ -385,6 +415,10 @@ def node_pool_create(
385
415
node_count : int ,
386
416
labels : Optional [Dict [str , str ]] = None ,
387
417
taints : List [Union [LKENodePoolTaint , Dict [str , Any ]]] = None ,
418
+ k8s_version : Optional [
419
+ Union [str , KubeVersion , TieredKubeVersion ]
420
+ ] = None ,
421
+ update_strategy : Optional [str ] = None ,
388
422
** kwargs ,
389
423
):
390
424
"""
@@ -399,7 +433,13 @@ def node_pool_create(
399
433
:param labels: A dict mapping labels to their values to apply to this pool.
400
434
:type labels: Dict[str, str]
401
435
:param taints: A list of taints to apply to this pool.
402
- :type taints: List of :any:`LKENodePoolTaint` or dict
436
+ :type taints: List of :any:`LKENodePoolTaint` or dict.
437
+ :param k8s_version: The Kubernetes version to use for this pool.
438
+ NOTE: This field is specific to enterprise clusters.
439
+ :type k8s_version: str, KubeVersion, or TieredKubeVersion
440
+ :param update_strategy: The strategy to use when updating this node pool.
441
+ NOTE: This field is specific to enterprise clusters.
442
+ :type update_strategy: str
403
443
:param kwargs: Any other arguments to pass to the API. See the API docs
404
444
for possible values.
405
445
@@ -409,6 +449,10 @@ def node_pool_create(
409
449
params = {
410
450
"type" : node_type ,
411
451
"count" : node_count ,
452
+ "labels" : labels ,
453
+ "taints" : taints ,
454
+ "k8s_version" : k8s_version ,
455
+ "update_strategy" : update_strategy ,
412
456
}
413
457
414
458
if labels is not None :
@@ -420,7 +464,9 @@ def node_pool_create(
420
464
params .update (kwargs )
421
465
422
466
result = self ._client .post (
423
- "{}/pools" .format (LKECluster .api_endpoint ), model = self , data = params
467
+ "{}/pools" .format (LKECluster .api_endpoint ),
468
+ model = self ,
469
+ data = drop_null_keys (_flatten_request_body_recursive (params )),
424
470
)
425
471
self .invalidate ()
426
472
0 commit comments