Skip to content

Commit

Permalink
chore: Update Airflow 2 GKE sample to use regional clusters (#7753)
Browse files Browse the repository at this point in the history
* Update Airflow 2 GKE sample to use regional clusters

* add commentabout cluster location
  • Loading branch information
leahecole authored Apr 20, 2022
1 parent 76a0e0c commit 651c9cd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions composer/workflows/gke_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
# [START composer_gkeoperator_fullconfig]
# TODO(developer): update with your values
PROJECT_ID = "my-project-id"
CLUSTER_ZONE = "us-west1-a"
# It is recommended to use regional clusters for increased reliability
# though passing a zone in the location parameter is also valid
CLUSTER_REGION = "us-west1"
CLUSTER_NAME = "example-cluster"
# [END composer_gkeoperator_minconfig]
# [END composer_gkeoperator_templateconfig]
Expand All @@ -58,7 +60,7 @@
create_cluster = GKECreateClusterOperator(
task_id="create_cluster",
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
body=CLUSTER,
)
# [END composer_gke_create_cluster]
Expand All @@ -70,7 +72,7 @@
# Name of task you want to run, used to generate Pod ID.
name="pod-ex-minimum",
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
cluster_name=CLUSTER_NAME,
# Entrypoint of the container, if not specified the Docker container's
# entrypoint is used. The cmds parameter is templated.
Expand All @@ -93,7 +95,7 @@
task_id="ex-kube-templates",
name="ex-kube-templates",
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
cluster_name=CLUSTER_NAME,
namespace="default",
image="bash",
Expand All @@ -120,7 +122,7 @@
kubernetes_affinity_ex = GKEStartPodOperator(
task_id="ex-pod-affinity",
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
cluster_name=CLUSTER_NAME,
name="ex-pod-affinity",
namespace="default",
Expand Down Expand Up @@ -170,7 +172,7 @@
task_id="ex-all-configs",
name="full",
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
cluster_name=CLUSTER_NAME,
namespace="default",
image="perl",
Expand Down Expand Up @@ -228,7 +230,7 @@
task_id="delete_cluster",
name=CLUSTER_NAME,
project_id=PROJECT_ID,
location=CLUSTER_ZONE,
location=CLUSTER_REGION,
)
# [END composer_gkeoperator_delete_cluster]

Expand Down

0 comments on commit 651c9cd

Please sign in to comment.