Volume not mounted in kubernetes executor

3/31/2020

I am having issues mounting my PV/PVC using kubernetes executor. I have the KubernetesPodOperator working with the volume mounts but I cannot see the volume mounted when trying to translate it into the kubernetes executor config. How do we write an executor which uses a specific PV/PVC?

My PV/PVC are both named airflow1data.

Here are two example tasks where I cannot see the mounted volume:

    ## Testing passing in PVC
    one_task = BashOperator(
        task_id="one_task",
        bash_command="df -h",
        executor_config={"KubernetesExecutor": {
                "image": "ubuntu:16.04", 
                "request_memory": '128Mi',
                "limit_memory": '128Mi',
                "volumes": [
                    {
                        "name": 'airflow1data', 
                        "persistentVolumeClaim": {"claimName": 'airflow1data'},
                        "hostPath": {"path": "/tmp/"}
                    }
                ],
                "volume_mounts": [
                    {
                        'mountPath': "/mnt/test/",
                        'name': "airflow1data" 
                    }
                ]
            }
        }
    )

    # Similar to example from sample dags in airflow repo
    four_task = BashOperator(
        task_id="four_task",
        bash_command="df -h",
        executor_config={
            "KubernetesExecutor": {
                "volumes": [
                    {
                        "name": "airflow1data",
                        "hostPath": {"path": "/tmp/"},
                    },
                ],
                "volume_mounts": [
                    {
                        "mountPath": "/foo/",
                        "name": "airflow1data",
                    },
                ]
            }
        }
    )
-- dchen71
airflow
kubernetes
python

0 Answers