airflow.providers.google.cloud.hooks.kubernetes_engine

This module contains a Google Kubernetes Engine Hook.

Module Contents

Classes

GKEHook

Hook for Google Kubernetes Engine APIs.

Attributes

OPERATIONAL_POLL_INTERVAL

airflow.providers.google.cloud.hooks.kubernetes_engine.OPERATIONAL_POLL_INTERVAL = 15[source]
class airflow.providers.google.cloud.hooks.kubernetes_engine.GKEHook(gcp_conn_id='google_cloud_default', delegate_to=None, location=None, impersonation_chain=None)[source]

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Hook for Google Kubernetes Engine APIs.

All the methods in the hook where project_id is used must be called with keyword arguments rather than positional.

get_cluster_manager_client(self)[source]

Returns ClusterManagerClient.

get_conn(self)[source]

Returns connection for the hook.

get_client(self)[source]
wait_for_operation(self, operation, project_id=None)[source]

Given an operation, continuously fetches the status from Google Cloud until either completion or an error occurring

Parameters
Returns

A new, updated operation fetched from Google Cloud

Return type

google.cloud.container_v1.types.Operation

get_operation(self, operation_name, project_id=None)[source]

Fetches the operation from Google Cloud

Parameters
  • operation_name (str) -- Name of operation to fetch

  • project_id (Optional[str]) -- Google Cloud project ID

Returns

The new, updated operation from Google Cloud

Return type

google.cloud.container_v1.types.Operation

delete_cluster(self, name, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None)[source]

Deletes the cluster, including the Kubernetes endpoint and all worker nodes. Firewalls and routes that were configured during cluster creation are also deleted. Other Google Compute Engine resources that might be in use by the cluster (e.g. load balancer resources) will not be deleted if they were not present at the initial create time.

Parameters
  • name (str) -- The name of the cluster to delete

  • project_id (str) -- Google Cloud project ID

  • retry (Union[google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault]) -- Retry object used to determine when/if to retry requests. If None is specified, requests will not be retried.

  • timeout (Optional[float]) -- The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

Returns

The full url to the delete operation if successful, else None

Return type

Optional[str]

create_cluster(self, cluster, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None)[source]

Creates a cluster, consisting of the specified number and type of Google Compute Engine instances.

Parameters
  • cluster (Union[Dict, google.cloud.container_v1.types.Cluster, None]) -- A Cluster protobuf or dict. If dict is provided, it must be of the same form as the protobuf message google.cloud.container_v1.types.Cluster

  • project_id (str) -- Google Cloud project ID

  • retry (Union[google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault]) -- A retry object (google.api_core.retry.Retry) used to retry requests. If None is specified, requests will not be retried.

  • timeout (Optional[float]) -- The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

Returns

The full url to the new, or existing, cluster

Raises

ParseError: On JSON parsing problems when trying to convert dict AirflowException: cluster is not dict type nor Cluster proto type

Return type

str

get_cluster(self, name, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None)[source]

Gets details of specified cluster

Parameters
  • name (str) -- The name of the cluster to retrieve

  • project_id (str) -- Google Cloud project ID

  • retry (Union[google.api_core.retry.Retry, google.api_core.gapic_v1.method._MethodDefault]) -- A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (Optional[float]) -- The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

Returns

google.cloud.container_v1.types.Cluster

Return type

google.cloud.container_v1.types.Cluster

Was this entry helpful?