1414 Region ,
1515 Type ,
1616)
17+ from linode_api4 .objects .base import _flatten_request_body_recursive
1718from linode_api4 .util import drop_null_keys
1819
1920
@@ -49,6 +50,26 @@ class KubeVersion(Base):
4950 }
5051
5152
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+
5273@dataclass
5374class LKENodePoolTaint (JSONObject ):
5475 """
@@ -154,6 +175,8 @@ class LKENodePool(DerivedBase):
154175 An LKE Node Pool describes a pool of Linode Instances that exist within an
155176 LKE Cluster.
156177
178+ NOTE: The k8s_version and update_strategy fields are only available for LKE Enterprise clusters.
179+
157180 API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lke-node-pool
158181 """
159182
@@ -175,6 +198,12 @@ class LKENodePool(DerivedBase):
175198 "tags" : Property (mutable = True , unordered = True ),
176199 "labels" : Property (mutable = True ),
177200 "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 ),
178207 }
179208
180209 def _parse_raw_node (
@@ -255,6 +284,7 @@ class LKECluster(Base):
255284 "pools" : Property (derived_class = LKENodePool ),
256285 "control_plane" : Property (mutable = True ),
257286 "apl_enabled" : Property (),
287+ "tier" : Property (),
258288 }
259289
260290 def invalidate (self ):
@@ -385,6 +415,10 @@ def node_pool_create(
385415 node_count : int ,
386416 labels : Optional [Dict [str , str ]] = None ,
387417 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 ,
388422 ** kwargs ,
389423 ):
390424 """
@@ -399,7 +433,13 @@ def node_pool_create(
399433 :param labels: A dict mapping labels to their values to apply to this pool.
400434 :type labels: Dict[str, str]
401435 :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
403443 :param kwargs: Any other arguments to pass to the API. See the API docs
404444 for possible values.
405445
@@ -409,6 +449,10 @@ def node_pool_create(
409449 params = {
410450 "type" : node_type ,
411451 "count" : node_count ,
452+ "labels" : labels ,
453+ "taints" : taints ,
454+ "k8s_version" : k8s_version ,
455+ "update_strategy" : update_strategy ,
412456 }
413457
414458 if labels is not None :
@@ -420,7 +464,9 @@ def node_pool_create(
420464 params .update (kwargs )
421465
422466 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 )),
424470 )
425471 self .invalidate ()
426472
0 commit comments