test_xxx.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. from airflow import DAG
  2. from datetime import datetime
  3. from airflow.operators.bash import BashOperator
  4. from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
  5. from airflow.configuration import conf
  6. namespace = conf.get("kubernetes", "NAMESPACE")
  7. # set the name that will be printed
  8. name = "dag_33"
  9. # instantiate the DAG
  10. with DAG(
  11. start_date=datetime(2022,6,1),
  12. catchup=False,
  13. schedule_interval='@daily',
  14. dag_id="auto_gen_test_job01"
  15. ) as dag:
  16. op_19 = KubernetesPodOperator(
  17. task_id="task_19_by_33",
  18. image="SXKJ:32775/pod_python:1.1",
  19. in_cluster=True,
  20. namespace=namespace,
  21. name="python_task_1664728952",
  22. random_name_suffix=True,
  23. labels={'app':'backend', 'env':'dev'},
  24. reattach_on_restart=True,
  25. is_delete_operator_pod=False,
  26. get_logs=True,
  27. log_events_on_failure=True,
  28. cmds=['/bin/bash', '-c', 'curl $FILE_TO_DOWNLOAD > run.py && python -b run.py '],
  29. env_vars={'SCRIPT': '', 'FILE_TO_DOWNLOAD': 'http://minio.default:9000/mytest/xxx/1664728951_hello_world.py'}
  30. )
  31. op_20 = KubernetesPodOperator(
  32. task_id="task_20_by_33",
  33. image="SXKJ:32775/pod_python:1.1",
  34. in_cluster=True,
  35. namespace=namespace,
  36. name="python_task_1664728953",
  37. random_name_suffix=True,
  38. labels={'app':'backend', 'env':'dev'},
  39. reattach_on_restart=True,
  40. is_delete_operator_pod=False,
  41. get_logs=True,
  42. log_events_on_failure=True,
  43. cmds=['/bin/bash', '-c', 'curl $FILE_TO_DOWNLOAD > run.py && python -b run.py '],
  44. env_vars={'SCRIPT': '', 'FILE_TO_DOWNLOAD': 'http://minio.default:9000/mytest/xxx/1664728953_hello_world.py'}
  45. )
  46. op_21 = KubernetesPodOperator(
  47. task_id="task_21_by_33",
  48. image="SXKJ:32775/pod_python:1.1",
  49. in_cluster=True,
  50. namespace=namespace,
  51. name="python_task_1664728954",
  52. random_name_suffix=True,
  53. labels={'app':'backend', 'env':'dev'},
  54. reattach_on_restart=True,
  55. is_delete_operator_pod=False,
  56. get_logs=True,
  57. log_events_on_failure=True,
  58. cmds=['/bin/bash', '-c', 'curl $FILE_TO_DOWNLOAD > run.py && python -b run.py '],
  59. env_vars={'SCRIPT': '', 'FILE_TO_DOWNLOAD': 'http://minio.default:9000/mytest/xxx/1664728954_hello_world.py'}
  60. )
  61. op_22 = KubernetesPodOperator(
  62. task_id="task_22_by_33",
  63. image="SXKJ:32775/pod_python:1.1",
  64. in_cluster=True,
  65. namespace=namespace,
  66. name="python_task_1664728975",
  67. random_name_suffix=True,
  68. labels={'app':'backend', 'env':'dev'},
  69. reattach_on_restart=True,
  70. is_delete_operator_pod=False,
  71. get_logs=True,
  72. log_events_on_failure=True,
  73. cmds=['/bin/bash', '-c', 'curl $FILE_TO_DOWNLOAD > run.py && python -b run.py '],
  74. env_vars={'SCRIPT': '', 'FILE_TO_DOWNLOAD': 'http://minio.default:9000/mytest/xxx/1664728975_hello_world.py'}
  75. )
  76. op_23 = KubernetesPodOperator(
  77. task_id="task_23_by_33",
  78. image="SXKJ:32775/pod_python:1.1",
  79. in_cluster=True,
  80. namespace=namespace,
  81. name="python_task_1664728976",
  82. random_name_suffix=True,
  83. labels={'app':'backend', 'env':'dev'},
  84. reattach_on_restart=True,
  85. is_delete_operator_pod=False,
  86. get_logs=True,
  87. log_events_on_failure=True,
  88. cmds=['/bin/bash', '-c', 'curl $FILE_TO_DOWNLOAD > run.py && python -b run.py '],
  89. env_vars={'SCRIPT': '', 'FILE_TO_DOWNLOAD': 'http://minio.default:9000/mytest/xxx/1664728976_hello_world.py'}
  90. )
  91. op_19 >> op_20
  92. op_20 >> op_21
  93. op_21 >> op_22
  94. op_22 >> op_23