Accessing airflow KubernetesPodOperator environment variables

589 Views Asked by At

I am trying to pass environment variables to my container using env_vars parameters of the KubernetesPodOperator.

        task_fetch = KubernetesPodOperator(
        task_id=FETCH,
        name=FETCH,
        image=K8S_PRODUCTION_IMAGE,
        in_cluster=K8S_IN_CLUSTER,
        namespace=K8S_NAMESPACE,
        get_logs=True,
        do_xcom_push=False,
        config_file="/app/.kube/config",
        affinity=K8S_AFFINITY,
        cmds=["echo $POSTGRES_URL"],
        env_vars={"POSTGRES_URL": "dummy"},
    )

I would expect the operator to print out dummy but it's not what's happening.

Is there any specific way of accessing that kind of env variables at runtime inside the container?

0

There are 0 best solutions below