Skip to content

Add GKEPodExecOperator for existing Pods - #72577

Merged
shahar1 merged 7 commits into
apache:mainfrom
AlejandroMorgante:add-gke-pod-exec-operator
Oct 1, 2026
Merged

shahar1 merged 7 commits into
apache:mainfrom
AlejandroMorgante:add-gke-pod-exec-operator

Conversation

@AlejandroMorgante

@AlejandroMorgante AlejandroMorgante commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Add GKEPodExecOperator to execute commands in running containers of existing GKE Pods. The operator reuses KubernetesPodExecOperator for execution while the existing GKE mixin supplies Google Cloud authentication, impersonation, cluster discovery, and public, internal, or DNS endpoint selection.

Unlike GKEStartPodOperator, this operator does not create, restart, or delete the Pod. This supports workloads whose lifecycle is owned by another platform while avoiding the external kubectl, kubeconfig, and shell setup otherwise needed from Airflow.

This builds on #71244.

Validation:

  • 103 Google Kubernetes Engine operator unit tests passed.
  • Focused mypy and scoped pre-commit/manual checks passed.
  • The GKE system test passed end-to-end against a real Autopilot cluster, including cluster creation,
    execution in an existing Pod, output verification, Pod deletion, and cluster teardown.

The system test can be reproduced from the Airflow checkout with GCP credentials forwarded to Breeze,
SYSTEM_TESTS_GCP_PROJECT configured in
files/airflow-breeze-config/environment_variables.env, and a unique environment ID:

SYSTEM_TESTS_ENV_ID=<unique-id> \
BREEZE_INIT_COMMAND='export GOOGLE_CLOUD_PROJECT="${SYSTEM_TESTS_GCP_PROJECT}"' \
breeze testing system-tests \
  --forward-credentials \
  --test-timeout 2400 \
  providers/google/tests/system/google/cloud/kubernetes_engine/example_kubernetes_engine.py \
  -q

Latest result: 1 passed in 1003.55s (0:16:43). The run completed resource teardown successfully.


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-5)

Generated-by: Codex (GPT-5) following the guidelines

@AlejandroMorgante

Copy link
Copy Markdown
Contributor Author

I also validated the operator end-to-end against a live GKE cluster. Airflow connected to the cluster, executed dbt build inside an existing running Pod, streamed the command output, and waited for completion. The task completed successfully with PASS=3 and ERROR=0, while the Pod remained running without restarts.

image image

Comment thread providers/google/pyproject.toml Resolved

@VladaZakharova VladaZakharova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, small fixes needed + answer Jarek's comments

@AlejandroMorgante
AlejandroMorgante force-pushed the add-gke-pod-exec-operator branch 4 times, most recently from 8db1378 to 8a7cc9e Compare September 23, 2026 20:26
@AlejandroMorgante

Copy link
Copy Markdown
Contributor Author

All done. Thank you for your feedback!

shahar1
shahar1 previously requested changes Oct 1, 2026

@shahar1 shahar1 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, blocking until cncf.kubernetes provider v10.22.0 lands (please ping if it's missed out)

Edit: 10.22.0 had been already release, so just updating the provider to be >= 10.22.0 would do.

@shahar1
shahar1 dismissed their stale review October 1, 2026 18:46

10.22.0 has already been released :D

Airflow users with externally managed GKE Pods currently need to configure Kubernetes authentication separately or shell out to kubectl. Reusing Google Cloud connections removes that setup while keeping Pod lifecycle ownership external.
Constructor defaults are already defined by Python and do not protect provider-specific behavior.
Concurrent system test runs can share a Kubernetes namespace, so a fixed Pod name causes collisions between environments.
A separately installed cncf-kubernetes provider can lack the Pod exec operator, leaving GKE imports with an unhelpful import error. Report the required provider version when this happens.
Migrating an existing Kubernetes Pod exec task to GKE can pass Kubernetes authentication settings that the GKE operator owns. A clear validation error makes the required change evident to the Dag author.
GKEPodExecOperator depends on KubernetesPodExecOperator, introduced in Kubernetes provider 10.22.0.

Generated-by: Codex (GPT-6)
@AlejandroMorgante
AlejandroMorgante force-pushed the add-gke-pod-exec-operator branch from 8a7cc9e to 9eed95a Compare October 1, 2026 18:58
@shahar1
shahar1 merged commit 0ec2672 into apache:main Oct 1, 2026
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants