airflow.providers.google.cloud.operators.kubernetes_engine

This module contains Google Kubernetes Engine operators.

Module Contents

class airflow.providers.google.cloud.operators.kubernetes_engine.GKEDeleteClusterOperator(*, name: str, location: str, project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', api_version: str = 'v2', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Deletes the cluster, including the Kubernetes endpoint and all worker nodes.

To delete a certain cluster, you must specify the project_id, the name of the cluster, the location that the cluster is in, and the task_id.

Operator Creation:

operator = GKEClusterDeleteOperator(
            task_id='cluster_delete',
            project_id='my-project',
            location='cluster-location'
            name='cluster-name')

See also

For more information on how to use this operator, take a look at the guide: Delete GKE cluster

Parameters
  • project_id (str) -- The Google Developers Console [project ID or project number]

  • name (str) -- The name of the resource to delete, in this case cluster name

  • location (str) -- The name of the Google Compute Engine zone in which the cluster resides.

  • gcp_conn_id (str) -- The connection ID to use connecting to Google Cloud.

  • api_version (str) -- The api version to use

  • impersonation_chain (Union[str, Sequence[str]]) -- Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'gcp_conn_id', 'name', 'location', 'api_version', 'impersonation_chain'][source]
_check_input(self)[source]
execute(self, context)[source]
class airflow.providers.google.cloud.operators.kubernetes_engine.GKECreateClusterOperator(*, location: str, body: Optional[Union[Dict, Cluster]], project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', api_version: str = 'v2', impersonation_chain: Optional[Union[str, Sequence[str]]] = None, **kwargs)[source]

Bases: airflow.models.BaseOperator

Create a Google Kubernetes Engine Cluster of specified dimensions The operator will wait until the cluster is created.

The minimum required to define a cluster to create is:

dict() ::
cluster_def = {'name': 'my-cluster-name',

'initial_node_count': 1}

or

Cluster proto ::

from google.cloud.container_v1.types import Cluster

cluster_def = Cluster(name='my-cluster-name', initial_node_count=1)

Operator Creation:

operator = GKEClusterCreateOperator(
            task_id='cluster_create',
            project_id='my-project',
            location='my-location'
            body=cluster_def)

See also

For more detail on about creating clusters have a look at the reference: google.cloud.container_v1.types.Cluster

See also

For more information on how to use this operator, take a look at the guide: Create GKE cluster

Parameters
  • project_id (str) -- The Google Developers Console [project ID or project number]

  • location (str) -- The name of the Google Compute Engine zone in which the cluster resides.

  • body (dict or google.cloud.container_v1.types.Cluster) -- The Cluster definition to create, can be protobuf or python dict, if dict it must match protobuf message Cluster

  • gcp_conn_id (str) -- The connection ID to use connecting to Google Cloud.

  • api_version (str) -- The api version to use

  • impersonation_chain (Union[str, Sequence[str]]) -- Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

template_fields = ['project_id', 'gcp_conn_id', 'location', 'api_version', 'body', 'impersonation_chain'][source]
_check_input(self)[source]
execute(self, context)[source]
airflow.providers.google.cloud.operators.kubernetes_engine.KUBE_CONFIG_ENV_VAR = KUBECONFIG[source]
class airflow.providers.google.cloud.operators.kubernetes_engine.GKEStartPodOperator(*, location: str, cluster_name: str, use_internal_ip: bool = False, project_id: Optional[str] = None, gcp_conn_id: str = 'google_cloud_default', **kwargs)[source]

Bases: airflow.providers.cncf.kubernetes.operators.kubernetes_pod.KubernetesPodOperator

Executes a task in a Kubernetes pod in the specified Google Kubernetes Engine cluster

This Operator assumes that the system has gcloud installed and has configured a connection id with a service account.

The minimum required to define a cluster to create are the variables task_id, project_id, location, cluster_name, name, namespace, and image

See also

For more detail about Kubernetes Engine authentication have a look at the reference: https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#internal_ip

See also

For more information on how to use this operator, take a look at the guide: Run a Pod on a GKE cluster

Parameters
  • location (str) -- The name of the Google Kubernetes Engine zone in which the cluster resides, e.g. 'us-central1-a'

  • cluster_name (str) -- The name of the Google Kubernetes Engine cluster the pod should be spawned in

  • use_internal_ip -- Use the internal IP address as the endpoint.

  • project_id (str) -- The Google Developers Console project id

  • gcp_conn_id (str) -- The google cloud connection id to use. This allows for users to specify a service account.

template_fields[source]
execute(self, context)[source]

Was this entry helpful?