or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication-security.mdcluster-configuration.mdcluster-management.mdindex.mdnode-pool-operations.mdoperations-management.md
tile.json

tessl/pypi-google-cloud-container

Google Cloud Container API client library for managing Google Kubernetes Engine clusters.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/google-cloud-container@2.59.x

To install, run

npx @tessl/cli install tessl/pypi-google-cloud-container@2.59.0

index.mddocs/

Google Cloud Container

Google Cloud Container API client library for managing Google Kubernetes Engine (GKE) clusters. This library provides comprehensive tools for creating, configuring, managing, and monitoring Kubernetes clusters on Google Cloud Platform through both stable (v1) and beta (v1beta1) APIs.

Package Information

  • Package Name: google-cloud-container
  • Package Type: pypi
  • Language: Python
  • Installation: pip install google-cloud-container

Core Imports

from google.cloud import container

For direct v1 API access:

from google.cloud import container_v1

For beta features (v1beta1 API with experimental functionality):

from google.cloud import container_v1beta1

# Create beta client with additional features
beta_client = container_v1beta1.ClusterManagerClient()

Basic Usage

from google.cloud import container

# Create a client using application default credentials
client = container.ClusterManagerClient()

# List all clusters in a project and zone
project_id = "my-project"
zone = "us-central1-a"
clusters = client.list_clusters(project_id=project_id, zone=zone)

for cluster in clusters.clusters:
    print(f"Cluster: {cluster.name}")
    print(f"Status: {cluster.status}")
    print(f"Node count: {cluster.current_node_count}")

# Get details of a specific cluster
cluster = client.get_cluster(
    project_id=project_id,
    zone=zone,
    cluster_id="my-cluster"
)

print(f"Cluster location: {cluster.location}")
print(f"Kubernetes version: {cluster.current_master_version}")

# For async operations
import asyncio
from google.cloud import container

async def async_example():
    async_client = container.ClusterManagerAsyncClient()
    
    # List clusters asynchronously
    clusters = await async_client.list_clusters(
        project_id=project_id,
        zone=zone
    )
    
    for cluster in clusters.clusters:
        print(f"Async - Cluster: {cluster.name}")

# asyncio.run(async_example())

Architecture

The Google Cloud Container client library is built on Google's GAPIC (Google API Client Generator) framework, providing:

  • Auto-generated clients from Protocol Buffer service definitions
  • Consistent patterns across all Google Cloud services
  • Multiple transport options (gRPC, HTTP/1.1 REST)
  • Async and sync clients for different programming models
  • Comprehensive type definitions with full IDE support

Key components:

  • ClusterManagerClient: Primary service client for cluster operations
  • Data types: Complete set of request/response objects and configuration classes
  • Transport layer: Pluggable transport supporting gRPC and REST protocols
  • Authentication: Integration with Google Cloud authentication and service accounts

Capabilities

Cluster Management

Core cluster lifecycle operations including creation, updates, deletion, and configuration management. Supports both basic and advanced cluster configurations with comprehensive node pool management.

def list_clusters(self, request=None, *, project_id=None, zone=None, parent=None, retry=..., timeout=..., metadata=...) -> ListClustersResponse: ...
def get_cluster(self, request=None, *, project_id=None, zone=None, cluster_id=None, name=None, retry=..., timeout=..., metadata=...) -> Cluster: ...
def create_cluster(self, request=None, *, project_id=None, zone=None, cluster=None, parent=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def update_cluster(self, request=None, *, project_id=None, zone=None, cluster_id=None, update=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def delete_cluster(self, request=None, *, project_id=None, zone=None, cluster_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...

Cluster Management

Node Pool Operations

Node pool lifecycle management including creation, scaling, updates, and configuration. Supports autoscaling, management policies, and rolling updates for node pools within clusters.

def list_node_pools(self, request=None, *, project_id=None, zone=None, cluster_id=None, parent=None, retry=..., timeout=..., metadata=...) -> ListNodePoolsResponse: ...
def get_node_pool(self, request=None, *, project_id=None, zone=None, cluster_id=None, node_pool_id=None, name=None, retry=..., timeout=..., metadata=...) -> NodePool: ...
def create_node_pool(self, request=None, *, project_id=None, zone=None, cluster_id=None, node_pool=None, parent=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def delete_node_pool(self, request=None, *, project_id=None, zone=None, cluster_id=None, node_pool_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
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=..., timeout=..., metadata=...) -> Operation: ...
def set_node_pool_autoscaling(self, request=None, *, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_node_pool_management(self, request=None, *, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_node_pool_size(self, request=None, *, retry=..., timeout=..., metadata=...) -> Operation: ...
def rollback_node_pool_upgrade(self, request=None, *, project_id=None, zone=None, cluster_id=None, node_pool_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def complete_node_pool_upgrade(self, request=None, *, retry=..., timeout=..., metadata=...) -> None: ...

Node Pool Operations

Cluster Configuration

Advanced cluster configuration including addons, networking, security, logging, monitoring, and maintenance policies. Covers both basic settings and enterprise-grade configurations.

def set_addons_config(self, request=None, *, project_id=None, zone=None, cluster_id=None, addons_config=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_logging_service(self, request=None, *, project_id=None, zone=None, cluster_id=None, logging_service=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_monitoring_service(self, request=None, *, project_id=None, zone=None, cluster_id=None, monitoring_service=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_network_policy(self, request=None, *, project_id=None, zone=None, cluster_id=None, network_policy=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_labels(self, request=None, *, project_id=None, zone=None, cluster_id=None, resource_labels=None, label_fingerprint=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_legacy_abac(self, request=None, *, project_id=None, zone=None, cluster_id=None, enabled=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_locations(self, request=None, *, project_id=None, zone=None, cluster_id=None, locations=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_maintenance_policy(self, request=None, *, project_id=None, zone=None, cluster_id=None, maintenance_policy=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def update_master(self, request=None, *, project_id=None, zone=None, cluster_id=None, master_version=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...

Cluster Configuration

Operations Management

Long-running operation monitoring and management for tracking cluster and node pool changes. Includes operation listing, status checking, and cancellation capabilities.

def list_operations(self, request=None, *, project_id=None, zone=None, parent=None, retry=..., timeout=..., metadata=...) -> ListOperationsResponse: ...
def get_operation(self, request=None, *, project_id=None, zone=None, operation_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def cancel_operation(self, request=None, *, project_id=None, zone=None, operation_id=None, name=None, retry=..., timeout=..., metadata=...) -> None: ...

Operations Management

Authentication and Security

Authentication configuration, security policies, and access control including master authentication, client certificates, workload identity, and network security policies.

def set_master_auth(self, request=None, *, project_id=None, zone=None, cluster_id=None, action=None, update=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def set_legacy_abac(self, request=None, *, project_id=None, zone=None, cluster_id=None, enabled=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def get_json_web_keys(self, request=None, *, parent=None, retry=..., timeout=..., metadata=...) -> GetJSONWebKeysResponse: ...

Authentication and Security

IP Rotation Management

Control plane IP address rotation for enhanced security, allowing gradual rotation of cluster master IP addresses while maintaining connectivity.

def start_ip_rotation(self, request=None, *, project_id=None, zone=None, cluster_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...
def complete_ip_rotation(self, request=None, *, project_id=None, zone=None, cluster_id=None, name=None, retry=..., timeout=..., metadata=...) -> Operation: ...

Service Information

Retrieve GKE service configuration and server information including supported Kubernetes versions and available features.

def get_server_config(self, request=None, *, project_id=None, zone=None, name=None, retry=..., timeout=..., metadata=...) -> ServerConfig: ...
def get_json_web_keys(self, request=None, *, retry=..., timeout=..., metadata=...) -> GetJSONWebKeysResponse: ...

Resource Discovery

Discover available network resources and subnets for cluster configuration and regional cluster deployment.

def list_usable_subnetworks(self, request=None, *, retry=..., timeout=..., metadata=...) -> ListUsableSubnetworksPager: ...

Autopilot Management

Autopilot cluster compatibility checking and management for hands-off cluster operations.

def check_autopilot_compatibility(self, request=None, *, retry=..., timeout=..., metadata=...) -> CheckAutopilotCompatibilityResponse: ...

Upgrade Information

Retrieve detailed upgrade information for clusters and node pools including available versions and upgrade paths.

def fetch_cluster_upgrade_info(self, request=None, *, name=None, retry=..., timeout=..., metadata=...) -> ClusterUpgradeInfo: ...
def fetch_node_pool_upgrade_info(self, request=None, *, name=None, retry=..., timeout=..., metadata=...) -> NodePoolUpgradeInfo: ...

Core Types

class ClusterManagerClient:
    """Google Kubernetes Engine Cluster Manager v1 (stable API)"""
    def __init__(self, *, credentials=None, transport=None, client_options=None, client_info=None): ...

class ClusterManagerAsyncClient:
    """Asynchronous client for Cluster Manager service v1"""
    def __init__(self, *, credentials=None, transport=None, client_options=None, client_info=None): ...

# Beta API clients (v1beta1) with additional experimental features
class container_v1beta1.ClusterManagerClient:
    """Google Kubernetes Engine Cluster Manager v1beta1 (beta API with experimental features)"""
    def __init__(self, *, credentials=None, transport=None, client_options=None, client_info=None): ...
    def list_locations(self, request=None, *, parent=None, retry=..., timeout=..., metadata=...) -> ListLocationsResponse: ...

class container_v1beta1.ClusterManagerAsyncClient:
    """Asynchronous client for Cluster Manager service v1beta1"""
    def __init__(self, *, credentials=None, transport=None, client_options=None, client_info=None): ...

class Cluster:
    """A Google Kubernetes Engine cluster"""
    name: str
    description: str
    initial_node_count: int
    node_config: NodeConfig
    master_auth: MasterAuth
    logging_service: str
    monitoring_service: str
    network: str
    cluster_ipv4_cidr: str
    addons_config: AddonsConfig
    subnetwork: str
    node_pools: MutableSequence[NodePool]
    locations: MutableSequence[str]
    enable_kubernetes_alpha: bool
    resource_labels: MutableMapping[str, str]
    label_fingerprint: str
    legacy_abac: LegacyAbac
    network_policy: NetworkPolicy
    ip_allocation_policy: IPAllocationPolicy
    master_authorized_networks_config: MasterAuthorizedNetworksConfig
    maintenance_policy: MaintenancePolicy
    binary_authorization: BinaryAuthorization
    autoscaling: ClusterAutoscaling
    network_config: NetworkConfig
    default_max_pods_constraint: MaxPodsConstraint
    resource_usage_export_config: ResourceUsageExportConfig
    authenticator_groups_config: AuthenticatorGroupsConfig
    private_cluster_config: PrivateClusterConfig
    database_encryption: DatabaseEncryption
    vertical_pod_autoscaling: VerticalPodAutoscaling
    shielded_nodes: ShieldedNodes
    release_channel: ReleaseChannel
    workload_identity_config: WorkloadIdentityConfig
    notification_config: NotificationConfig
    confidential_nodes: ConfidentialNodes
    self_link: str
    zone: str
    endpoint: str
    initial_cluster_version: str
    current_master_version: str
    current_node_version: str
    create_time: str
    status: str
    status_message: str
    node_ipv4_cidr_size: int
    services_ipv4_cidr: str
    instance_group_urls: MutableSequence[str]
    current_node_count: int
    expire_time: str
    location: str
    enable_tpu: bool
    tpu_ipv4_cidr_block: str
    conditions: MutableSequence[StatusCondition]
    autopilot: Autopilot
    id: str
    node_pool_defaults: NodePoolDefaults
    logging_config: LoggingConfig
    monitoring_config: MonitoringConfig
    node_pool_auto_config: NodePoolAutoConfig
    etag: str
    fleet: Fleet
    security_posture_config: SecurityPostureConfig
    enable_k8s_beta_apis: K8sBetaAPIConfig
    enterprise_config: EnterpriseConfig
    secret_manager_config: SecretManagerConfig
    compliance_posture_config: CompliancePostureConfig

class NodePool:
    """NodePool contains the name and configuration for a cluster's node pool"""
    name: str
    config: NodeConfig
    initial_node_count: int
    locations: MutableSequence[str]
    network_config: NodeNetworkConfig
    self_link: str
    version: str
    instance_group_urls: MutableSequence[str]
    status: str
    status_message: str
    autoscaling: NodePoolAutoscaling
    management: NodeManagement
    max_pods_constraint: MaxPodsConstraint
    conditions: MutableSequence[StatusCondition]
    pod_ipv4_cidr_size: int
    upgrade_settings: UpgradeSettings
    placement_policy: PlacementPolicy
    update_info: UpdateInfo
    etag: str
    queued_provisioning: QueuedProvisioning
    best_effort_provisioning: BestEffortProvisioning

class Operation:
    """Represents an operation resource"""
    name: str
    zone: str
    operation_type: str
    status: str
    detail: str
    status_message: str
    self_link: str
    target_link: str
    location: str
    start_time: str
    end_time: str
    progress: OperationProgress
    cluster_conditions: MutableSequence[StatusCondition]
    nodepool_conditions: MutableSequence[StatusCondition]
    error: Status

# Core Configuration Types
class NodeConfig:
    """Parameters that describe the nodes in a cluster"""
    machine_type: str
    disk_size_gb: int
    oauth_scopes: MutableSequence[str]
    service_account: str
    metadata: MutableMapping[str, str]
    image_type: str
    labels: MutableMapping[str, str]
    local_ssd_count: int
    tags: MutableSequence[str]
    preemptible: bool
    disk_type: str
    min_cpu_platform: str
    workload_metadata_config: WorkloadMetadataConfig
    taints: MutableSequence[NodeTaint]
    shielded_instance_config: ShieldedInstanceConfig
    linux_node_config: LinuxNodeConfig
    kubelet_config: NodeKubeletConfig

class MasterAuth:
    """Master authentication configuration"""
    username: str
    password: str
    client_certificate_config: ClientCertificateConfig
    cluster_ca_certificate: str
    client_certificate: str
    client_key: str

class AddonsConfig:
    """Configuration for the addons that can be automatically spun up in the cluster"""
    http_load_balancing: HttpLoadBalancing
    horizontal_pod_autoscaling: HorizontalPodAutoscaling
    kubernetes_dashboard: KubernetesDashboard
    network_policy_config: NetworkPolicyConfig
    cloud_run_config: CloudRunConfig
    dns_cache_config: DnsCacheConfig
    config_connector_config: ConfigConnectorConfig
    gce_persistent_disk_csi_driver_config: GcePersistentDiskCsiDriverConfig

class NetworkPolicy:
    """Configuration options for the NetworkPolicy feature"""
    provider: str
    enabled: bool

class IPAllocationPolicy:
    """Configuration for controlling how IPs are allocated in the cluster"""
    use_ip_aliases: bool
    create_subnetwork: bool
    subnetwork_name: str
    cluster_ipv4_cidr: str
    node_ipv4_cidr: str
    services_ipv4_cidr: str
    cluster_secondary_range_name: str
    services_secondary_range_name: str
    cluster_ipv4_cidr_block: str
    node_ipv4_cidr_block: str
    services_ipv4_cidr_block: str

class ServerConfig:
    """Kubernetes Engine service configuration"""
    default_cluster_version: str
    valid_node_versions: MutableSequence[str]
    default_image_type: str
    valid_image_types: MutableSequence[str]
    valid_master_versions: MutableSequence[str]
    channels: MutableSequence[ReleaseChannelConfig]

# Request/Response Types
class ListClustersResponse:
    """Response for listing clusters"""
    clusters: MutableSequence[Cluster]
    missing_zones: MutableSequence[str]

class ListNodePoolsResponse:
    """Response for listing node pools"""
    node_pools: MutableSequence[NodePool]

class ListOperationsResponse:
    """Response for listing operations"""
    operations: MutableSequence[Operation]
    missing_zones: MutableSequence[str]

class GetJSONWebKeysResponse:
    """Response for getting JSON Web Keys"""
    keys: MutableSequence[Jwk]

class CheckAutopilotCompatibilityResponse:
    """Response for checking Autopilot compatibility"""
    issues: MutableSequence[AutopilotCompatibilityIssue]
    summary: str

class ClusterUpgradeInfo:
    """Cluster upgrade information"""
    upgrade_type: str
    current_version: str
    target_version: str

class NodePoolUpgradeInfo:
    """Node pool upgrade information"""
    upgrade_type: str
    current_version: str
    target_version: str

# Additional Essential Types
class ClusterUpdate:
    """ClusterUpdate describes an update to the cluster"""
    desired_node_version: str
    desired_monitoring_service: str
    desired_addons_config: AddonsConfig
    desired_node_pool_id: str
    desired_image_type: str
    desired_database_encryption: DatabaseEncryption
    desired_workload_identity_config: WorkloadIdentityConfig
    desired_shielded_nodes: ShieldedNodes
    desired_private_cluster_config: PrivateClusterConfig

class NodePoolAutoscaling:
    """NodePoolAutoscaling contains information required by cluster autoscaler"""
    enabled: bool
    min_node_count: int
    max_node_count: int
    autoprovisioned: bool

class NodeManagement:
    """NodeManagement defines the set of node management services"""
    auto_upgrade: bool
    auto_repair: bool
    upgrade_options: AutoUpgradeOptions

# Additional Supporting Types
class StatusCondition:
    """StatusCondition describes why a cluster or a node pool has a certain status"""
    code: str
    message: str

class OperationProgress:
    """Information about operation (or operation stage) progress"""
    name: str
    status: str
    stages: MutableSequence[OperationProgress]

class Status:
    """The Status type defines a logical error model"""
    code: int
    message: str
    details: MutableSequence[Any]

class ListUsableSubnetworksPager:
    """Pager for list_usable_subnetworks results"""
    def __iter__(self) -> Iterator[UsableSubnetwork]: ...

class Jwk:
    """JSON Web Key as specified by RFC 7517"""
    kty: str
    alg: str
    use: str
    kid: str
    n: str
    e: str

class AutopilotCompatibilityIssue:
    """AutopilotCompatibilityIssue contains information about a specific compatibility issue"""
    last_observation: str
    constraint_type: str
    incompatibility_type: str
    subjects: MutableSequence[str]
    documentation: str

# Type aliases for common generic types
MutableSequence = typing.MutableSequence
MutableMapping = typing.MutableMapping