Google Cloud Container API client library for managing Google Kubernetes Engine clusters.
—
Advanced cluster configuration management for Google Kubernetes Engine. This module provides comprehensive functionality for configuring cluster addons, networking, security, logging, monitoring, and maintenance policies.
Configure cluster addons including HTTP load balancing, horizontal pod autoscaling, Kubernetes dashboard, and network policy enforcement.
def set_addons_config(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
addons_config=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the addons for a specific 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 to upgrade.
addons_config (AddonsConfig): Required. The desired configurations for the various addons.
name (str): The name (project, location, cluster) of the cluster to set addons.
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 addons configuration.
"""Usage example:
from google.cloud.container_v1.types import AddonsConfig, HttpLoadBalancing, HorizontalPodAutoscaling, NetworkPolicyConfig
addons_config = AddonsConfig(
http_load_balancing=HttpLoadBalancing(disabled=False),
horizontal_pod_autoscaling=HorizontalPodAutoscaling(disabled=False),
network_policy_config=NetworkPolicyConfig(disabled=False),
dns_cache_config=DnsCacheConfig(enabled=True)
)
operation = client.set_addons_config(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
addons_config=addons_config
)Configure the logging service for cluster and workload logs.
def set_logging_service(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
logging_service=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the logging service for a specific 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 to upgrade.
logging_service (str): Required. The logging service the cluster should use to write logs.
name (str): The name (project, location, cluster) of the cluster to set logging.
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 logging service configuration.
"""Usage example:
operation = client.set_logging_service(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
logging_service="logging.googleapis.com/kubernetes"
)Configure the monitoring service for cluster metrics and health.
def set_monitoring_service(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
monitoring_service=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the monitoring service for a specific 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 to upgrade.
monitoring_service (str): Required. The monitoring service the cluster should use to write metrics.
name (str): The name (project, location, cluster) of the cluster to set monitoring.
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 monitoring service configuration.
"""Usage example:
operation = client.set_monitoring_service(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
monitoring_service="monitoring.googleapis.com/kubernetes"
)Configure network policy enforcement for pod-to-pod communication.
def set_network_policy(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
network_policy=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Enables or disables Network Policy 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.
network_policy (NetworkPolicy): Required. Configuration options for the NetworkPolicy feature.
name (str): The name (project, location, cluster) of the cluster to set networking policy.
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 network policy configuration.
"""Usage example:
from google.cloud.container_v1.types import NetworkPolicy
network_policy = NetworkPolicy(
enabled=True,
provider=NetworkPolicy.Provider.CALICO
)
operation = client.set_network_policy(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
network_policy=network_policy
)Set or update cluster labels for organization and billing.
def set_labels(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
resource_labels=None,
label_fingerprint=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets labels on 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.
resource_labels (MutableMapping[str, str]): Required. The labels to set for that cluster.
label_fingerprint (str): Required. The fingerprint of the previous set of labels for this resource.
name (str): The name (project, location, cluster) of the cluster to set labels.
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 labels configuration.
"""Usage example:
labels = {
"environment": "production",
"team": "platform",
"cost-center": "engineering"
}
operation = client.set_labels(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
resource_labels=labels,
label_fingerprint=cluster.label_fingerprint
)Configure legacy Attribute-Based Access Control (deprecated).
def set_legacy_abac(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
enabled=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Enables or disables the ABAC authorization mechanism on 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.
enabled (bool): Required. Whether ABAC authorization will be enabled in the cluster.
name (str): The name (project, location, cluster) of the cluster to set legacy abac.
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 ABAC configuration.
"""Configure cluster maintenance windows and policies.
def set_maintenance_policy(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
maintenance_policy=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the maintenance policy 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 to update.
maintenance_policy (MaintenancePolicy): Required. The maintenance policy to be set for the cluster.
name (str): The name (project, location, cluster) of the cluster to set maintenance policy.
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 maintenance policy configuration.
"""Usage example:
from google.cloud.container_v1.types import MaintenancePolicy, MaintenanceWindow, DailyMaintenanceWindow
maintenance_policy = MaintenancePolicy(
window=MaintenanceWindow(
daily_maintenance_window=DailyMaintenanceWindow(
start_time="02:00",
duration="PT4H"
)
)
)
operation = client.set_maintenance_policy(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
maintenance_policy=maintenance_policy
)Update the Kubernetes master version.
def update_master(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
master_version=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Updates the master for a specific 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 to upgrade.
master_version (str): Required. The Kubernetes version to change the master to.
name (str): The name (project, location, cluster) of the cluster to update.
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 master update.
"""Usage example:
operation = client.update_master(
project_id="my-project",
zone="us-central1-a",
cluster_id="my-cluster",
master_version="1.21.14-gke.700"
)Set the locations where cluster nodes can be placed.
def set_locations(
self,
request=None, *,
project_id=None,
zone=None,
cluster_id=None,
locations=None,
name=None,
retry=gapic_v1.method.DEFAULT,
timeout=None,
metadata=()
) -> Operation:
"""
Sets the locations for a specific cluster. Deprecated.
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 to upgrade.
locations (MutableSequence[str]): Required. The desired list of Google Compute Engine zones.
name (str): The name (project, location, cluster) of the cluster to set locations.
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 location configuration.
"""class SetAddonsConfigRequest:
"""SetAddonsConfigRequest sets the addons associated with the cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
addons_config: AddonsConfig # Required
name: str # Required
class SetLoggingServiceRequest:
"""SetLoggingServiceRequest sets the logging service of a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
logging_service: str # Required
name: str # Required
class SetMonitoringServiceRequest:
"""SetMonitoringServiceRequest sets the monitoring service of a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
monitoring_service: str # Required
name: str # Required
class SetNetworkPolicyRequest:
"""SetNetworkPolicyRequest enables/disables network policy for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
network_policy: NetworkPolicy # Required
name: str # Required
class SetLabelsRequest:
"""SetLabelsRequest sets the Google Cloud Platform labels on a Google Container Engine cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
resource_labels: MutableMapping[str, str] # Required
label_fingerprint: str # Required
name: str # Required
class SetLegacyAbacRequest:
"""SetLegacyAbacRequest enables or disables the ABAC authorization mechanism."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
enabled: bool # Required
name: str # Required
class SetMaintenancePolicyRequest:
"""SetMaintenancePolicyRequest sets the maintenance policy for a cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
maintenance_policy: MaintenancePolicy # Required
name: str # Required
class UpdateMasterRequest:
"""UpdateMasterRequest updates the master of the cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
master_version: str # Required
name: str # Required
class SetLocationsRequest:
"""SetLocationsRequest sets the locations of the cluster."""
project_id: str # Deprecated
zone: str # Deprecated
cluster_id: str # Deprecated
locations: MutableSequence[str] # Required
name: str # Required
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
dns_cache_config: DnsCacheConfig
config_connector_config: ConfigConnectorConfig
gce_persistent_disk_csi_driver_config: GcePersistentDiskCsiDriverConfig
gcp_filestore_csi_driver_config: GcpFilestoreCsiDriverConfig
gcs_fuse_csi_driver_config: GcsFuseCsiDriverConfig
cloud_run_config: CloudRunConfig
gke_backup_agent_config: GkeBackupAgentConfig
stateful_ha_config: StatefulHAConfig
ray_operator_config: RayOperatorConfig
class NetworkPolicy:
"""Configuration for NetworkPolicy. This only tracks whether the addon is enabled or not."""
provider: NetworkPolicy.Provider
enabled: bool
class Provider(proto.Enum):
"""The set of available providers."""
PROVIDER_UNSPECIFIED = 0
CALICO = 1
class MaintenancePolicy:
"""MaintenancePolicy defines the maintenance policy to be used for the cluster."""
window: MaintenanceWindow
resource_version: str
class MaintenanceWindow:
"""MaintenanceWindow defines the maintenance window to be used for the cluster."""
daily_maintenance_window: DailyMaintenanceWindow
recurring_window: RecurringTimeWindow
maintenance_exclusions: MutableMapping[str, TimeWindow]
class DailyMaintenanceWindow:
"""Time window specified for daily maintenance operations."""
start_time: str
duration: strInstall with Tessl CLI
npx tessl i tessl/pypi-google-cloud-container