1 year ago

#354650

test-img

Elie Ladias

Accessing airflow KubernetesPodOperator environment variables

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?

kubernetes

airflow

kubernetespodoperator

0 Answers

Your Answer

Accepted video resources