Skip to content

KubernetesPodOperator templating the image parameter #12100

@HarryDunham

Description

@HarryDunham

Apache Airflow version: 1.10.11

Kubernetes version (if you are using kubernetes) (use kubectl version): 1.17

Environment: AWS

Background:
Per the KubernetesPodOperator template fields, image is listed as a parameter which can be templated. However, this is not reflected in the parameters documentation since it is missing the typical (templated) specifier within the docs. Therefore, it's ambiguous whether it can be templated or not.

What happened:
A task was defined via the KubernetesPodOperator with a jinja template within the image parameter:

t0 = KubernetesPodOperator(
    task_name='dummy_task',
    task_id='dummy_id',
    name='dummy-pod',
    namespace='default',
    dag=dag,
    affinity=affinity,
    tolerations=tolerations,
    image='ACC_ID.dkr.REGION.amazonaws.com/IMAGE:{{ dag_run.conf.image_version }}'
)

Yet the template was not processed through the jinja templating engine. Per the logs:

Failed to apply default image tag "ACC_ID.dkr.ecr.REGION.amazonaws.com/IMAGE_NAME:{{ dag_run.conf.image_version }}": couldn't parse image reference "ACC_ID.dkr.ecr.REGION.amazonaws.com/IMAGE_NAME:{{ dag_run.conf.image_version }}": invalid reference format

What you expected to happen:
The image string to resolve to ACC_ID.dkr.REGION.amazonaws.com/IMAGE:IMAGE_VERSION.

How to reproduce it:
Create a task via the KubernetesPodOperator and supply a jinja template to the image parameter of the operator.

Conclusion:
Should the template fields be altered to reflect this behavior or is this a bug and not working as intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions