Skip to content

Allow passing config_path as a parameter to KubernetesExecutor #46293

Open

Description

@pablo-moreno-mancebo

Description

Currently, when using executor_config with KubernetesExecutor, the config_file path must be hardcoded. If we try to pass it dynamically using a Jinja template ("{{ params.config_path }}"), it results in an error.

Example of a working static configuration:

executor_config={"KubernetesExecutor": {"config_file": "/opt/airflow/config/kubernetes/docker-desktop-config.yaml"}}

However, if we attempt to pass it dynamically, it fails:

executor_config={"KubernetesExecutor": {"config_file": "{{ params.config_path }}"}}

This would be useful when deploying DAGs across different environments (e.g., multiple regions) without hardcoding paths.

Proposed Solution:

Modify executor_config to allow templating in KubernetesExecutor.config_file, similar to other templated parameters in Airflow.

Use case/motivation

This would be useful when deploying DAGs across different environments (e.g., multiple regions) without hardcoding paths.
Airflow should allow config_file to accept templated values, resolving them at runtime.
This feature would improve flexibility when running KubernetesExecutor tasks that need different configurations based on dynamic parameters.
Would love to hear thoughts from the community on this! Thanks! 😊

Related issues

This feature would improve Airflow’s flexibility in hybrid execution environments and align with the goals of AIP-61. Would love to hear thoughts from the community on this! 🚀

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:feature
    needs-triage
    on Jan 30, 2025
  2. boring-cyborg commented on Jan 30, 2025

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. added
    provider:cncf-kubernetes
    on Jan 30, 2025
  4. potiuk commented on Jan 31, 2025

    @potiuk
    Member

    If you can take a look at propose a PR solving it, yes I think it would be useful. But it needs a deep look in the code whether it's possible, also with Airflow 3 changes / Task SDK changes in progress, likely doing it after this is completed, is a good idea.

  5. added and removed
    needs-triage
    on Jan 31, 2025
  6. insomnes commented on Feb 1, 2025

    @insomnes
    Contributor

    Are you sure you can rewrite it with?

    executor_config={"KubernetesExecutor": {"config_file": "/opt/airflow/config/kubernetes/docker-desktop-config.yaml"}}
    

    I've dug through the code and also experimented a bit, and couldn't find any way to rewrite the initial config file for KubernetesExecutor. Am I missing something? Any of the executor_config I've tried to use with deprecated KubernetesExecutor variant except the empty one led to the error:

    {kubernetes_executor.py:355} ERROR - Invalid executor_config for TaskInstanceKey
    
  7. Maryam3107 commented on Feb 2, 2025

    @Maryam3107

    Description

    Currently, when using executor_config with KubernetesExecutor, the config_file path must be hardcoded. If we try to pass it dynamically using a Jinja template ("{{ params.config_path }}"), it results in an error.

    Example of a working static configuration:

    executor_config={"KubernetesExecutor": {"config_file": "/opt/airflow/config/kubernetes/docker-desktop-config.yaml"}}
    However, if we attempt to pass it dynamically, it fails:

    executor_config={"KubernetesExecutor": {"config_file": "{{ params.config_path }}"}}
    This would be useful when deploying DAGs across different environments (e.g., multiple regions) without hardcoding paths.

    Proposed Solution:

    Modify executor_config to allow templating in KubernetesExecutor.config_file, similar to other templated parameters in Airflow.

    Use case/motivation

    This would be useful when deploying DAGs across different environments (e.g., multiple regions) without hardcoding paths. Airflow should allow config_file to accept templated values, resolving them at runtime. This feature would improve flexibility when running KubernetesExecutor tasks that need different configurations based on dynamic parameters. Would love to hear thoughts from the community on this! Thanks! 😊

    Related issues

    This feature would improve Airflow’s flexibility in hybrid execution environments and align with the goals of AIP-61. Would love to hear thoughts from the community on this! 🚀

    Are you willing to submit a PR?

    • Yes I am willing to submit a PR!

    Code of Conduct

    I can solve this problem. kindly assign it to me

  8. Nataneljpwd commented on Jul 2, 2025

    @Nataneljpwd
    Contributor

    Hello, could anyone clarify further on what needs to be done?
    How will an end result dag look like?
    I'm looking into it and this setting is possible on task and dag level, which one should be implemented? Isn't it better to implement it for the task instead?

  9. potiuk commented on Mar 2, 2026

    @potiuk
    Member

    @Maryam3107 We are unassigning you from this issue as part of our updated assignment policy.

    This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.

    We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.

  10. kunaljubce commented on Jun 6, 2026

    @kunaljubce
    Contributor

    I started looking into this but given the changes introduced in #10756 and thereafter, any support for KubernetesExecutor inside executor_config seems to be deprecated now, raising a TypeError instead - https://github.com/astronomer/airflow/blob/main/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/pod_generator.py#L202-L206

    Will wait for @jedcunningham/any other Airflow PMC for their expertise on K8sOperator to comment on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuekind:featureprovider:cncf-kubernetes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions