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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .types import GetNodeMetadataRequest
from .types import GetNodeRequest
from .types import GetPoolRequest
from .types import GetUserDataRequest
from .types import GetVersionRequest
from .types import ListClusterACLRulesRequest
from .types import ListClusterACLRulesResponse
Expand Down Expand Up @@ -148,6 +149,7 @@
"GetNodeMetadataRequest",
"GetNodeRequest",
"GetPoolRequest",
"GetUserDataRequest",
"GetVersionRequest",
"ListClusterACLRulesRequest",
"ListClusterACLRulesResponse",
Expand Down
60 changes: 51 additions & 9 deletions scaleway-async/scaleway_async/k8s/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,15 +1047,15 @@ async def create_pool(
cluster_id: str,
node_type: str,
autoscaling: bool,
size: int,
region: Optional[ScwRegion] = None,
name: Optional[str] = None,
placement_group_id: Optional[str] = None,
size: int,
autohealing: bool,
public_ip_disabled: bool,
min_size: Optional[int] = None,
max_size: Optional[int] = None,
container_runtime: Optional[Runtime] = None,
autohealing: bool,
public_ip_disabled: bool,
tags: Optional[list[str]] = None,
kubelet_args: Optional[dict[str, str]] = None,
upgrade_policy: Optional[CreatePoolRequestUpgradePolicy] = None,
Expand All @@ -1067,22 +1067,23 @@ async def create_pool(
taints: Optional[list[CoreV1Taint]] = None,
startup_taints: Optional[list[CoreV1Taint]] = None,
private_network_id: Optional[str] = None,
user_data: Optional[dict[str, str]] = None,
) -> Pool:
"""
Create a new Pool in a Cluster.
Create a new pool in a specific Kubernetes cluster.
:param cluster_id: Cluster ID to which the pool will be attached.
:param node_type: Node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster.
:param autoscaling: Defines whether the autoscaling feature is enabled for the pool.
:param size: Size (number of nodes) of the pool.
:param region: Region to target. If none is passed will use default region from the config.
:param name: Pool name.
:param placement_group_id: Placement group ID in which all the nodes of the pool will be created, placement groups are limited to 20 instances.
:param size: Size (number of nodes) of the pool.
:param autohealing: Defines whether the autohealing feature is enabled for the pool.
:param public_ip_disabled: Defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway.
:param min_size: Defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
:param max_size: Defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
:param container_runtime: Customization of the container runtime is available for each pool.
:param autohealing: Defines whether the autohealing feature is enabled for the pool.
:param public_ip_disabled: Defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway.
:param tags: Tags associated with the pool, see [managing tags](https://www.scaleway.com/en/docs/kubernetes/api-cli/managing-tags).
:param kubelet_args: Kubelet arguments to be used by this pool. Note that this feature is experimental.
:param upgrade_policy: Defines how node provisioning should behave during pool version upgrade.
Expand All @@ -1097,6 +1098,7 @@ async def create_pool(
:param taints: Kubernetes taints applied and reconciled on the nodes.
:param startup_taints: Kubernetes taints applied at node creation but not reconciled afterwards.
:param private_network_id: Private network where the nodes are attached. Should be member of the same VPC as the API Server.
:param user_data: User data applied and reconciled with the pool.
:return: :class:`Pool <Pool>`

Usage:
Expand Down Expand Up @@ -1125,15 +1127,15 @@ async def create_pool(
cluster_id=cluster_id,
node_type=node_type,
autoscaling=autoscaling,
size=size,
region=region,
name=name or random_name(prefix="pool"),
placement_group_id=placement_group_id,
size=size,
autohealing=autohealing,
public_ip_disabled=public_ip_disabled,
min_size=min_size,
max_size=max_size,
container_runtime=container_runtime,
autohealing=autohealing,
public_ip_disabled=public_ip_disabled,
tags=tags,
kubelet_args=kubelet_args,
upgrade_policy=upgrade_policy,
Expand All @@ -1145,6 +1147,7 @@ async def create_pool(
taints=taints,
startup_taints=startup_taints,
private_network_id=private_network_id,
user_data=user_data,
),
self.client,
),
Expand Down Expand Up @@ -1504,6 +1507,45 @@ async def set_pool_labels(
self._throw_on_error(res)
return unmarshal_Pool(res.json())

async def get_user_data(
self,
*,
pool_id: str,
key: str,
region: Optional[ScwRegion] = None,
) -> ScwFile:
"""
Get a pool related user data.
Retrieve specific user data content for a given pool.
Tip: add `?dl=1` at the end of the URL to directly retrieve the base64 decoded content of your user data.
:param pool_id: Pool the user data will be attached to.
:param key: User data key to retrieved.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`ScwFile <ScwFile>`

Usage:
::

result = await api.get_user_data(
pool_id="example",
key="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_pool_id = validate_path_param("pool_id", pool_id)
param_key = validate_path_param("key", key)

res = self._request(
"GET",
f"/k8s/v1/regions/{param_region}/pools/{param_pool_id}/user-data/{param_key}",
)

self._throw_on_error(res)
return unmarshal_ScwFile(res.json())

async def get_node_metadata(
self,
*,
Expand Down
21 changes: 12 additions & 9 deletions scaleway-async/scaleway_async/k8s/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,15 +1766,21 @@ def marshal_CreatePoolRequest(
if request.autoscaling is not None:
output["autoscaling"] = request.autoscaling

if request.size is not None:
output["size"] = request.size

if request.name is not None:
output["name"] = request.name

if request.placement_group_id is not None:
output["placement_group_id"] = request.placement_group_id

if request.size is not None:
output["size"] = request.size

if request.autohealing is not None:
output["autohealing"] = request.autohealing

if request.public_ip_disabled is not None:
output["public_ip_disabled"] = request.public_ip_disabled

if request.min_size is not None:
output["min_size"] = request.min_size

Expand All @@ -1784,12 +1790,6 @@ def marshal_CreatePoolRequest(
if request.container_runtime is not None:
output["container_runtime"] = request.container_runtime

if request.autohealing is not None:
output["autohealing"] = request.autohealing

if request.public_ip_disabled is not None:
output["public_ip_disabled"] = request.public_ip_disabled

if request.tags is not None:
output["tags"] = request.tags

Expand Down Expand Up @@ -1833,6 +1833,9 @@ def marshal_CreatePoolRequest(
if request.private_network_id is not None:
output["private_network_id"] = request.private_network_id

if request.user_data is not None:
output["user_data"] = {key: value for key, value in request.user_data.items()}

return output


Expand Down
23 changes: 23 additions & 0 deletions scaleway-async/scaleway_async/k8s/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,11 @@ class CreatePoolRequest:
Private network where the nodes are attached. Should be member of the same VPC as the API Server.
"""

user_data: Optional[dict[str, str]] = field(default_factory=dict)
"""
User data applied and reconciled with the pool.
"""


@dataclass
class DeleteACLRuleRequest:
Expand Down Expand Up @@ -1660,6 +1665,24 @@ class GetPoolRequest:
"""


@dataclass
class GetUserDataRequest:
pool_id: str
"""
Pool the user data will be attached to.
"""

key: str
"""
User data key to retrieved.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class GetVersionRequest:
version_name: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from .types import GetNodeMetadataRequest
from .types import GetNodeRequest
from .types import GetPoolRequest
from .types import GetUserDataRequest
from .types import GetVersionRequest
from .types import ListClusterACLRulesRequest
from .types import ListClusterACLRulesResponse
Expand Down Expand Up @@ -148,6 +149,7 @@
"GetNodeMetadataRequest",
"GetNodeRequest",
"GetPoolRequest",
"GetUserDataRequest",
"GetVersionRequest",
"ListClusterACLRulesRequest",
"ListClusterACLRulesResponse",
Expand Down
60 changes: 51 additions & 9 deletions scaleway/scaleway/k8s/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,15 +1047,15 @@ def create_pool(
cluster_id: str,
node_type: str,
autoscaling: bool,
size: int,
region: Optional[ScwRegion] = None,
name: Optional[str] = None,
placement_group_id: Optional[str] = None,
size: int,
autohealing: bool,
public_ip_disabled: bool,
min_size: Optional[int] = None,
max_size: Optional[int] = None,
container_runtime: Optional[Runtime] = None,
autohealing: bool,
public_ip_disabled: bool,
tags: Optional[list[str]] = None,
kubelet_args: Optional[dict[str, str]] = None,
upgrade_policy: Optional[CreatePoolRequestUpgradePolicy] = None,
Expand All @@ -1067,22 +1067,23 @@ def create_pool(
taints: Optional[list[CoreV1Taint]] = None,
startup_taints: Optional[list[CoreV1Taint]] = None,
private_network_id: Optional[str] = None,
user_data: Optional[dict[str, str]] = None,
) -> Pool:
"""
Create a new Pool in a Cluster.
Create a new pool in a specific Kubernetes cluster.
:param cluster_id: Cluster ID to which the pool will be attached.
:param node_type: Node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster.
:param autoscaling: Defines whether the autoscaling feature is enabled for the pool.
:param size: Size (number of nodes) of the pool.
:param region: Region to target. If none is passed will use default region from the config.
:param name: Pool name.
:param placement_group_id: Placement group ID in which all the nodes of the pool will be created, placement groups are limited to 20 instances.
:param size: Size (number of nodes) of the pool.
:param autohealing: Defines whether the autohealing feature is enabled for the pool.
:param public_ip_disabled: Defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway.
:param min_size: Defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
:param max_size: Defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
:param container_runtime: Customization of the container runtime is available for each pool.
:param autohealing: Defines whether the autohealing feature is enabled for the pool.
:param public_ip_disabled: Defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway.
:param tags: Tags associated with the pool, see [managing tags](https://www.scaleway.com/en/docs/kubernetes/api-cli/managing-tags).
:param kubelet_args: Kubelet arguments to be used by this pool. Note that this feature is experimental.
:param upgrade_policy: Defines how node provisioning should behave during pool version upgrade.
Expand All @@ -1097,6 +1098,7 @@ def create_pool(
:param taints: Kubernetes taints applied and reconciled on the nodes.
:param startup_taints: Kubernetes taints applied at node creation but not reconciled afterwards.
:param private_network_id: Private network where the nodes are attached. Should be member of the same VPC as the API Server.
:param user_data: User data applied and reconciled with the pool.
:return: :class:`Pool <Pool>`

Usage:
Expand Down Expand Up @@ -1125,15 +1127,15 @@ def create_pool(
cluster_id=cluster_id,
node_type=node_type,
autoscaling=autoscaling,
size=size,
region=region,
name=name or random_name(prefix="pool"),
placement_group_id=placement_group_id,
size=size,
autohealing=autohealing,
public_ip_disabled=public_ip_disabled,
min_size=min_size,
max_size=max_size,
container_runtime=container_runtime,
autohealing=autohealing,
public_ip_disabled=public_ip_disabled,
tags=tags,
kubelet_args=kubelet_args,
upgrade_policy=upgrade_policy,
Expand All @@ -1145,6 +1147,7 @@ def create_pool(
taints=taints,
startup_taints=startup_taints,
private_network_id=private_network_id,
user_data=user_data,
),
self.client,
),
Expand Down Expand Up @@ -1504,6 +1507,45 @@ def set_pool_labels(
self._throw_on_error(res)
return unmarshal_Pool(res.json())

def get_user_data(
self,
*,
pool_id: str,
key: str,
region: Optional[ScwRegion] = None,
) -> ScwFile:
"""
Get a pool related user data.
Retrieve specific user data content for a given pool.
Tip: add `?dl=1` at the end of the URL to directly retrieve the base64 decoded content of your user data.
:param pool_id: Pool the user data will be attached to.
:param key: User data key to retrieved.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`ScwFile <ScwFile>`

Usage:
::

result = api.get_user_data(
pool_id="example",
key="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_pool_id = validate_path_param("pool_id", pool_id)
param_key = validate_path_param("key", key)

res = self._request(
"GET",
f"/k8s/v1/regions/{param_region}/pools/{param_pool_id}/user-data/{param_key}",
)

self._throw_on_error(res)
return unmarshal_ScwFile(res.json())

def get_node_metadata(
self,
*,
Expand Down
Loading
Loading