コード例 #1
0
        nodegroup_subnets="{{ dag_run.conf['nodegroup_subnets'] }}",
        nodegroup_role_arn="{{ dag_run.conf['nodegroup_role_arn'] }}",
    )

    await_create_nodegroup = EKSNodegroupStateSensor(
        task_id='wait_for_create_nodegroup',
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
        nodegroup_name="{{ dag_run.conf['nodegroup_name'] }}",
        target_state=NodegroupStates.ACTIVE,
    )

    start_pod = EKSPodOperator(
        task_id="run_pod",
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
        image="amazon/aws-cli:latest",
        cmds=["sh", "-c", "ls"],
        labels={"demo": "hello_world"},
        get_logs=True,
        # Delete the pod when it reaches its final state, or the execution is interrupted.
        is_delete_operator_pod=True,
    )

    delete_nodegroup = EKSDeleteNodegroupOperator(
        task_id='delete_eks_nodegroup',
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
        nodegroup_name="{{ dag_run.conf['nodegroup_name'] }}",
    )

    await_delete_nodegroup = EKSNodegroupStateSensor(
        task_id='wait_for_delete_nodegroup',
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
        nodegroup_name="{{ dag_run.conf['nodegroup_name'] }}",
コード例 #2
0
        fargate_profile_name=FARGATE_PROFILE_NAME,
        selectors=SELECTORS,
    )
    # [END howto_operator_eks_create_fargate_profile]

    await_create_fargate_profile = EKSFargateProfileStateSensor(
        task_id='wait_for_create_fargate_profile',
        fargate_profile_name=FARGATE_PROFILE_NAME,
        target_state=FargateProfileStates.ACTIVE,
    )

    start_pod = EKSPodOperator(
        task_id="run_pod",
        pod_name="run_pod",
        image="amazon/aws-cli:latest",
        cmds=["sh", "-c", "echo Test Airflow; date"],
        labels={"demo": "hello_world"},
        get_logs=True,
        # Delete the pod when it reaches its final state, or the execution is interrupted.
        is_delete_operator_pod=True,
    )

    # [START howto_operator_eks_delete_fargate_profile]
    delete_fargate_profile = EKSDeleteFargateProfileOperator(
        task_id='delete_eks_fargate_profile',
        fargate_profile_name=FARGATE_PROFILE_NAME,
    )
    # [END howto_operator_eks_delete_fargate_profile]

    await_delete_fargate_profile = EKSFargateProfileStateSensor(
        task_id='wait_for_delete_fargate_profile',
        fargate_profile_name=FARGATE_PROFILE_NAME,