example_kubernetes.py 570 B

123456789101112131415161718
  1. write_xcom = KubernetesPodOperator(
  2. namespace='default',
  3. image='alpine',
  4. cmds=["sh", "-c", "mkdir -p /airflow/xcom/;echo '[1,2,3,4]' > /airflow/xcom/return.json"],
  5. name="write-xcom",
  6. do_xcom_push=True,
  7. is_delete_operator_pod=True,
  8. in_cluster=True,
  9. task_id="write-xcom",
  10. get_logs=True,
  11. )
  12. pod_task_xcom_result = BashOperator(
  13. bash_command="echo \"{{ task_instance.xcom_pull('write-xcom')[0] }}\"",
  14. task_id="pod_task_xcom_result",
  15. )
  16. write_xcom >> pod_task_xcom_result