Google Cloud Container API client library for managing Google Kubernetes Engine clusters.
—
Node pool lifecycle management within Google Kubernetes Engine clusters. Node pools are groups of nodes within a cluster that share the same configuration, allowing for heterogeneous clusters with different node types and capabilities.
Retrieve all node pools for a specified cluster.
def list_node_pools(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
parent=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> ListNodePoolsResponse:
"""
Lists the node pools for a cluster.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
parent (str): The parent (project, location, cluster) where the node pools will be listed.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
ListNodePoolsResponse: Response containing the list of node pools.
"""Usage example:
from google.cloud import container
client = container.ClusterManagerClient()
node_pools = client.list_node_pools(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster"
)
for pool in node_pools.node_pools:
print(f"Node pool: {pool.name}")
print(f"Status: {pool.status}")
print(f"Initial node count: {pool.initial_node_count}")
print(f"Machine type: {pool.config.machine_type}")Retrieve detailed information about a specific node pool.
def get_node_pool(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> NodePool:
"""
Retrieves the requested node pool.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
name (str): The name (project, location, cluster, node pool) of the node pool to get.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
NodePool: The node pool information.
"""Usage example:
node_pool = client.get_node_pool(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
node_pool_id="default-pool"
)
print(f"Node pool name: {node_pool.name}")
print(f"Machine type: {node_pool.config.machine_type}")
print(f"Disk size: {node_pool.config.disk_size_gb}")
print(f"Node count: {node_pool.initial_node_count}")Create a new node pool within an existing cluster.
def create_node_pool(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool=None,
parent=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Creates a node pool for a cluster.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool (NodePool): Required. The node pool to create.
parent (str): The parent (project, location, cluster) where the node pool will be created.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the node pool creation.
"""Usage example:
from google.cloud.container_v1.types import NodePool, NodeConfig, NodeManagement
# Configure node pool
node_pool_config = NodePool(
name="gpu-pool",
initial_node_count=2,
config=NodeConfig(
machine_type="n1-standard-4",
disk_size_gb=100,
oauth_scopes=[
"https://www.googleapis.com/auth/cloud-platform"
],
accelerators=[
AcceleratorConfig(
accelerator_count=1,
accelerator_type="nvidia-tesla-k80"
)
]
),
management=NodeManagement(
auto_upgrade=True,
auto_repair=True
)
)
operation = client.create_node_pool(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
node_pool=node_pool_config
)
print(f"Creating node pool. Operation: {operation.name}")Update an existing node pool's configuration.
def update_node_pool(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
node_version=None,
image_type=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Updates the version and/or image type for the specified node pool.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
node_version (str): Required. The Kubernetes version to change the nodes to.
image_type (str): Required. The desired image type for the node pool.
name (str): The name (project, location, cluster, node pool) of the node pool to update.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the node pool update.
"""Usage example:
operation = client.update_node_pool(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
node_pool_id="default-pool",
node_version="1.21.14-gke.700",
image_type="COS_CONTAINERD"
)
print(f"Updating node pool. Operation: {operation.name}")Delete an existing node pool from a cluster.
def delete_node_pool(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Deletes a node pool from a cluster.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool to delete.
name (str): The name (project, location, cluster, node pool) of the node pool to delete.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the node pool deletion.
"""Configure autoscaling settings for a node pool.
def set_node_pool_autoscaling(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
autoscaling=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the autoscaling settings for the specified node pool.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
autoscaling (NodePoolAutoscaling): Required. Autoscaling configuration for the node pool.
name (str): The name (project, location, cluster, node pool) of the node pool to set autoscaling for.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the autoscaling configuration.
"""Usage example:
from google.cloud.container_v1.types import NodePoolAutoscaling
autoscaling_config = NodePoolAutoscaling(
enabled=True,
min_node_count=1,
max_node_count=10,
total_min_node_count=1,
total_max_node_count=100
)
operation = client.set_node_pool_autoscaling(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
node_pool_id="default-pool",
autoscaling=autoscaling_config
)Configure management settings for a node pool.
def set_node_pool_management(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
management=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the NodeManagement options for a node pool.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
management (NodeManagement): Required. NodeManagement configuration for the node pool.
name (str): The name (project, location, cluster, node pool) of the node pool to set management properties.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the management configuration.
"""Usage example:
from google.cloud.container_v1.types import NodeManagement, AutoUpgradeOptions
management_config = NodeManagement(
auto_upgrade=True,
auto_repair=True,
upgrade_options=AutoUpgradeOptions(
auto_upgrade_start_time="2023-01-01T02:00:00Z",
description="Weekly maintenance window"
)
)
operation = client.set_node_pool_management(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
node_pool_id="default-pool",
management=management_config
)Set the size of a node pool.
def set_node_pool_size(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
node_count=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the size for a specific node pool.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
node_count (int): Required. The desired node count for the pool.
name (str): The name (project, location, cluster, node pool) of the node pool to set size.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the size change.
"""Complete or rollback node pool upgrades.
def complete_node_pool_upgrade(
self,
request=None, *,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> None:
"""
CompleteNodePoolUpgrade will signal an on-going node pool upgrade to complete.
Args:
name (str): The name (project, location, cluster, node pool) of the node pool to complete upgrade.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
"""
def rollback_node_pool_upgrade(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
node_pool_id=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Rolls back a previously Aborted or Failed NodePool upgrade.
Args:
project_id (str): Deprecated. The Google Developers Console project ID or project number.
zone (str): Deprecated. The name of the Google Compute Engine zone.
cluster_id (str): Deprecated. The name of the cluster.
node_pool_id (str): Deprecated. The name of the node pool.
name (str): The name (project, location, cluster, node pool) of the node pool to rollback.
Format: projects/{project_id}/locations/{location}/clusters/{cluster_id}/nodePools/{node_pool_id}
retry: Retry configuration.
timeout (float): Request timeout in seconds.
metadata: Additional gRPC metadata.
Returns:
Operation: An operation representing the rollback.
"""class ListNodePoolsRequest:
"""ListNodePoolsRequest lists the node pools for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
parent: str # Required. Format: projects/{project}/locations/{location}/clusters/{cluster}
class ListNodePoolsResponse:
"""ListNodePoolsResponse is the result of ListNodePoolsRequest."""
node_pools: MutableSequence[NodePool]
class GetNodePoolRequest:
"""GetNodePoolRequest retrieves a node pool for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
name: str # Required. Format: projects/{project}/locations/{location}/clusters/{cluster}/nodePools/{node_pool}
class CreateNodePoolRequest:
"""CreateNodePoolRequest creates a node pool for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool: NodePool # Required
parent: str # Required. Format: projects/{project}/locations/{location}/clusters/{cluster}
class DeleteNodePoolRequest:
"""DeleteNodePoolRequest deletes a node pool for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
name: str # Required. Format: projects/{project}/locations/{location}/clusters/{cluster}/nodePools/{node_pool}
class UpdateNodePoolRequest:
"""UpdateNodePoolRequest updates a node pool for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
node_version: str # Required
image_type: str # Required
name: str # Required
class SetNodePoolAutoscalingRequest:
"""SetNodePoolAutoscalingRequest sets the autoscaler settings of a node pool."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
autoscaling: NodePoolAutoscaling # Required
name: str # Required
class SetNodePoolManagementRequest:
"""SetNodePoolManagementRequest sets the node management properties of a node pool."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
management: NodeManagement # Required
name: str # Required
class SetNodePoolSizeRequest:
"""SetNodePoolSizeRequest sets the size of a node pool."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
node_pool_id: str # Deprecated
node_count: int # Required
name: str # Required
class NodePoolAutoscaling:
"""NodePoolAutoscaling contains information required by cluster autoscaler."""
enabled: bool
min_node_count: int
max_node_count: int
total_min_node_count: int
total_max_node_count: int
location_policy: NodePoolAutoscaling.LocationPolicy
class NodeManagement:
"""NodeManagement defines the set of node management services."""
auto_upgrade: bool
auto_repair: bool
upgrade_options: AutoUpgradeOptions
class AutoUpgradeOptions:
"""AutoUpgradeOptions defines the set of options for the user to control how the Auto Upgrades will proceed."""
auto_upgrade_start_time: str
description: strInstall with Tessl CLI
npx tessl i tessl/pypi-google-cloud-container