You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "nailo2c (via GitHub)" <gi...@apache.org> on 2025/12/23 09:47:31 UTC
[PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
nailo2c opened a new pull request, #59747:
URL: https://github.com/apache/airflow/pull/59747
Closes: #40005
# Why
Based on my experience resolving k8s-related bugs, it's quite inconvenience to build and upload a k8s image when I only make a small change.
# How
After some research, I decided integrate [Skaffold](https://github.com/GoogleContainerTools/skaffold) into `breeze k8s` to improve the development experience.
# What
[WIP]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #59747:
URL: https://github.com/apache/airflow/pull/59747
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "nailo2c (via GitHub)" <gi...@apache.org>.
nailo2c commented on code in PR #59747:
URL: https://github.com/apache/airflow/pull/59747#discussion_r2646781063
##########
dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:
##########
@@ -1256,6 +1386,116 @@ def deploy_airflow(
sys.exit(return_code)
+@kubernetes_group.command(
+ name="dev",
+ help=(
+ "Run skaffold dev loop to sync dags and airflow-core sources to running pods "
+ "(scheduler/triggerer/dag-processor hot-reload; API server/webserver UI not by default)."
+ ),
+ context_settings=dict(
+ ignore_unknown_options=True,
+ ),
+)
+@option_python
+@option_kubernetes_version
+@option_executor
+@option_log_level
+@option_use_standard_naming
+@option_multi_namespace_mode
+@option_dags_path
+@option_dags_dest
+@option_skaffold_deploy
+@option_verbose
+@option_dry_run
+@click.argument("skaffold_args", nargs=-1, type=click.UNPROCESSED)
+def dev(
+ python: str,
+ kubernetes_version: str,
+ executor: str,
+ log_level: str,
+ use_standard_naming: bool,
+ multi_namespace_mode: bool,
+ dags_path: Path,
+ dags_dest: str,
+ deploy: bool,
+ skaffold_args: tuple[str, ...],
+):
+ result = sync_virtualenv(force_venv_setup=False)
+ if result.returncode != 0:
+ sys.exit(result.returncode)
+ make_sure_kubernetes_tools_are_installed()
+ make_sure_skaffold_installed()
+ dags_path_abs = dags_path
+ if not dags_path_abs.is_absolute():
+ dags_path_abs = AIRFLOW_ROOT_PATH / dags_path_abs
+ dags_path_abs = dags_path_abs.resolve()
+ if not dags_path_abs.is_dir():
+ get_console().print(f"[error]DAGs path does not exist or is not a directory: {dags_path_abs}")
+ sys.exit(1)
+ try:
+ dags_relative_path = dags_path_abs.relative_to(AIRFLOW_ROOT_PATH).as_posix()
+ except ValueError:
+ get_console().print(f"[error]DAGs path must be under the Airflow sources: {AIRFLOW_ROOT_PATH}")
+ sys.exit(1)
+ if not get_kind_cluster_config_path(python=python, kubernetes_version=kubernetes_version).exists():
+ get_console().print(
+ f"\n[warning]Cluster for Python {python} and Kubernetes {kubernetes_version} "
+ "has not been created yet.\n"
+ )
+ get_console().print(
+ "[info]Run: "
+ f"`breeze k8s create-cluster --python {python} --kubernetes-version {kubernetes_version}`\n"
+ )
+ sys.exit(1)
+ skaffold_config = _build_skaffold_config(
+ python=python,
+ kubernetes_version=kubernetes_version,
+ executor=executor,
+ use_standard_naming=use_standard_naming,
+ multi_namespace_mode=multi_namespace_mode,
+ dags_relative_path=dags_relative_path,
+ dags_dest=dags_dest,
+ log_level=log_level,
+ )
+ if not deploy:
+ get_console().print(
+ "[info]Running skaffold without deploying Helm resources. "
+ "If sync cannot find pods, rerun with --deploy."
+ )
+ with tempfile.TemporaryDirectory(prefix="skaffold_") as tmp_dir:
+ dev_env_values = {
+ "scheduler": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "triggerer": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "dagProcessor": {"env": [{"name": "DEV_MODE", "value": "true"}]},
Review Comment:
`DEV_MODE` makes the API server serve `airflow/ui/dev/index.html` (see `app.py`), and that file hard‑codes assets from the Vite dev server at `http://localhost:5173`. In k8s dev we don't run or expose that dev server, so the UI assets fail to load and the page renders blank. That's why we intentionally don't enable `DEV_MODE` for the API server by default.
refs:
[app.py](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/api_fastapi/core_api/app.py)
[airflow/ui/dev/index.html](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/ui/dev/index.html)
[airflow/ui/CONTRIBUTING.md](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/ui/CONTRIBUTING.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3698503702
#promo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3687252426
One comment here - (might be follow-up) - if we run airflow commands in the chart with --dev flags , we could also simply synchronize airflow's source code - not only Dags. We already have built-in hot-reload in airflow components when they are run in `--dev` mode, so all we need is to sync the source change to the right folder.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3691811193
### Backport failed to create: v3-1-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/20512282515'> Run details </a>
<table>
<tr>
<th>Status</th>
<th>Branch</th>
<th>Result</th>
</tr>
<tr>
<td>❌</td>
<td>v3-1-test</td>
<td><a href="https://github.com/apache/airflow/commit/9f874c3a6f65efdbf84deaefe18c62a4851eeb56"><img src='https://img.shields.io/badge/Commit-9f874c3-red' alt='Commit Link'></a></td>
</tr>
</table>
You can attempt to backport this manually by running:
```bash
cherry_picker 9f874c3 v3-1-test
```
This should apply the commit to the v3-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.
After you have resolved the conflicts, you can continue the backport process by running:
```bash
cherry_picker --continue
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3698553694
#protm
for me as well.
I forgot to add the tag while reviewing the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #59747:
URL: https://github.com/apache/airflow/pull/59747#discussion_r2645998915
##########
dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:
##########
@@ -1256,6 +1386,116 @@ def deploy_airflow(
sys.exit(return_code)
+@kubernetes_group.command(
+ name="dev",
+ help=(
+ "Run skaffold dev loop to sync dags and airflow-core sources to running pods "
+ "(scheduler/triggerer/dag-processor hot-reload; API server/webserver UI not by default)."
+ ),
+ context_settings=dict(
+ ignore_unknown_options=True,
+ ),
+)
+@option_python
+@option_kubernetes_version
+@option_executor
+@option_log_level
+@option_use_standard_naming
+@option_multi_namespace_mode
+@option_dags_path
+@option_dags_dest
+@option_skaffold_deploy
+@option_verbose
+@option_dry_run
+@click.argument("skaffold_args", nargs=-1, type=click.UNPROCESSED)
+def dev(
+ python: str,
+ kubernetes_version: str,
+ executor: str,
+ log_level: str,
+ use_standard_naming: bool,
+ multi_namespace_mode: bool,
+ dags_path: Path,
+ dags_dest: str,
+ deploy: bool,
+ skaffold_args: tuple[str, ...],
+):
+ result = sync_virtualenv(force_venv_setup=False)
+ if result.returncode != 0:
+ sys.exit(result.returncode)
+ make_sure_kubernetes_tools_are_installed()
+ make_sure_skaffold_installed()
+ dags_path_abs = dags_path
+ if not dags_path_abs.is_absolute():
+ dags_path_abs = AIRFLOW_ROOT_PATH / dags_path_abs
+ dags_path_abs = dags_path_abs.resolve()
+ if not dags_path_abs.is_dir():
+ get_console().print(f"[error]DAGs path does not exist or is not a directory: {dags_path_abs}")
+ sys.exit(1)
+ try:
+ dags_relative_path = dags_path_abs.relative_to(AIRFLOW_ROOT_PATH).as_posix()
+ except ValueError:
+ get_console().print(f"[error]DAGs path must be under the Airflow sources: {AIRFLOW_ROOT_PATH}")
+ sys.exit(1)
+ if not get_kind_cluster_config_path(python=python, kubernetes_version=kubernetes_version).exists():
+ get_console().print(
+ f"\n[warning]Cluster for Python {python} and Kubernetes {kubernetes_version} "
+ "has not been created yet.\n"
+ )
+ get_console().print(
+ "[info]Run: "
+ f"`breeze k8s create-cluster --python {python} --kubernetes-version {kubernetes_version}`\n"
+ )
+ sys.exit(1)
+ skaffold_config = _build_skaffold_config(
+ python=python,
+ kubernetes_version=kubernetes_version,
+ executor=executor,
+ use_standard_naming=use_standard_naming,
+ multi_namespace_mode=multi_namespace_mode,
+ dags_relative_path=dags_relative_path,
+ dags_dest=dags_dest,
+ log_level=log_level,
+ )
+ if not deploy:
+ get_console().print(
+ "[info]Running skaffold without deploying Helm resources. "
+ "If sync cannot find pods, rerun with --deploy."
+ )
+ with tempfile.TemporaryDirectory(prefix="skaffold_") as tmp_dir:
+ dev_env_values = {
+ "scheduler": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "triggerer": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "dagProcessor": {"env": [{"name": "DEV_MODE", "value": "true"}]},
Review Comment:
I think we could include the API Server as well (though it was still labeled `webserver` in the chart). I don’t see any downsides to having an API Server with hot reload support in k8s tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "nailo2c (via GitHub)" <gi...@apache.org>.
nailo2c commented on code in PR #59747:
URL: https://github.com/apache/airflow/pull/59747#discussion_r2646781063
##########
dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py:
##########
@@ -1256,6 +1386,116 @@ def deploy_airflow(
sys.exit(return_code)
+@kubernetes_group.command(
+ name="dev",
+ help=(
+ "Run skaffold dev loop to sync dags and airflow-core sources to running pods "
+ "(scheduler/triggerer/dag-processor hot-reload; API server/webserver UI not by default)."
+ ),
+ context_settings=dict(
+ ignore_unknown_options=True,
+ ),
+)
+@option_python
+@option_kubernetes_version
+@option_executor
+@option_log_level
+@option_use_standard_naming
+@option_multi_namespace_mode
+@option_dags_path
+@option_dags_dest
+@option_skaffold_deploy
+@option_verbose
+@option_dry_run
+@click.argument("skaffold_args", nargs=-1, type=click.UNPROCESSED)
+def dev(
+ python: str,
+ kubernetes_version: str,
+ executor: str,
+ log_level: str,
+ use_standard_naming: bool,
+ multi_namespace_mode: bool,
+ dags_path: Path,
+ dags_dest: str,
+ deploy: bool,
+ skaffold_args: tuple[str, ...],
+):
+ result = sync_virtualenv(force_venv_setup=False)
+ if result.returncode != 0:
+ sys.exit(result.returncode)
+ make_sure_kubernetes_tools_are_installed()
+ make_sure_skaffold_installed()
+ dags_path_abs = dags_path
+ if not dags_path_abs.is_absolute():
+ dags_path_abs = AIRFLOW_ROOT_PATH / dags_path_abs
+ dags_path_abs = dags_path_abs.resolve()
+ if not dags_path_abs.is_dir():
+ get_console().print(f"[error]DAGs path does not exist or is not a directory: {dags_path_abs}")
+ sys.exit(1)
+ try:
+ dags_relative_path = dags_path_abs.relative_to(AIRFLOW_ROOT_PATH).as_posix()
+ except ValueError:
+ get_console().print(f"[error]DAGs path must be under the Airflow sources: {AIRFLOW_ROOT_PATH}")
+ sys.exit(1)
+ if not get_kind_cluster_config_path(python=python, kubernetes_version=kubernetes_version).exists():
+ get_console().print(
+ f"\n[warning]Cluster for Python {python} and Kubernetes {kubernetes_version} "
+ "has not been created yet.\n"
+ )
+ get_console().print(
+ "[info]Run: "
+ f"`breeze k8s create-cluster --python {python} --kubernetes-version {kubernetes_version}`\n"
+ )
+ sys.exit(1)
+ skaffold_config = _build_skaffold_config(
+ python=python,
+ kubernetes_version=kubernetes_version,
+ executor=executor,
+ use_standard_naming=use_standard_naming,
+ multi_namespace_mode=multi_namespace_mode,
+ dags_relative_path=dags_relative_path,
+ dags_dest=dags_dest,
+ log_level=log_level,
+ )
+ if not deploy:
+ get_console().print(
+ "[info]Running skaffold without deploying Helm resources. "
+ "If sync cannot find pods, rerun with --deploy."
+ )
+ with tempfile.TemporaryDirectory(prefix="skaffold_") as tmp_dir:
+ dev_env_values = {
+ "scheduler": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "triggerer": {"env": [{"name": "DEV_MODE", "value": "true"}]},
+ "dagProcessor": {"env": [{"name": "DEV_MODE", "value": "true"}]},
Review Comment:
`DEV_MODE` makes the API server serve `airflow/ui/dev/index.html` (see `app.py`), and that file hard‑codes assets from the Vite dev server at `http://localhost:5173`. In k8s dev we don't run or expose that dev server, so the UI assets fail to load and the page renders blank. That's why we intentionally don't enable `DEV_MODE` for the API server by default.
refs:
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/api_fastapi/core_api/app.py
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/ui/dev/index.html
https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/ui/CONTRIBUTING.md
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3691878062
No backorting needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "nailo2c (via GitHub)" <gi...@apache.org>.
nailo2c commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3690121002
Yes, exactly. That's why I chose `Skaffold`, it handles syncing the source code directly to the running containers without rebuilding images. Combined with the --dev flag, this should give us the fast iteration experience we need :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add 'breeze k8s dev' command for hot-reloading DAGs and core sources (#40005) [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #59747:
URL: https://github.com/apache/airflow/pull/59747#issuecomment-3687222131
WOWOWOWOWOW !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org