Beispiel #1
0
        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'] }}",
        target_state=NodegroupStates.NONEXISTENT,
    )

    delete_cluster = EKSDeleteClusterOperator(
        task_id='delete_eks_cluster',
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
    )

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        cluster_name="{{ dag_run.conf['cluster_name'] }}",
        target_state=ClusterStates.NONEXISTENT,
    )

    (create_cluster >> await_create_cluster >> create_nodegroup >>
     await_create_nodegroup >> start_pod >> delete_nodegroup >>
     await_delete_nodegroup >> delete_cluster >> await_delete_cluster)
Beispiel #2
0
        pod_name="run_pod",
        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',
        nodegroup_name="{{ dag_run.conf['nodegroup_name'] }}",
    )

    await_delete_nodegroup = EKSNodegroupStateSensor(
        task_id='wait_for_delete_nodegroup',
        nodegroup_name="{{ dag_run.conf['nodegroup_name'] }}",
        target_state=NodegroupStates.NONEXISTENT,
    )

    delete_cluster = EKSDeleteClusterOperator(task_id='delete_eks_cluster', )

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        target_state=ClusterStates.NONEXISTENT,
    )

    (create_cluster >> await_create_cluster >> create_nodegroup >>
     await_create_nodegroup >> start_pod >> delete_nodegroup >>
     await_delete_nodegroup >> delete_cluster >> await_delete_cluster)
Beispiel #3
0
    # [END howto_operator_eks_pod_operator]

    # [START howto_operator_eks_delete_nodegroup]
    delete_nodegroup = EKSDeleteNodegroupOperator(
        task_id='delete_eks_nodegroup',
        cluster_name=CLUSTER_NAME,
        nodegroup_name=NODEGROUP_NAME)
    # [END howto_operator_eks_delete_nodegroup]

    await_delete_nodegroup = EKSNodegroupStateSensor(
        task_id='wait_for_delete_nodegroup',
        cluster_name=CLUSTER_NAME,
        nodegroup_name=NODEGROUP_NAME,
        target_state=NodegroupStates.NONEXISTENT,
    )

    # [START howto_operator_eks_delete_cluster]
    delete_cluster = EKSDeleteClusterOperator(task_id='delete_eks_cluster',
                                              cluster_name=CLUSTER_NAME)
    # [END howto_operator_eks_delete_cluster]

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        cluster_name=CLUSTER_NAME,
        target_state=ClusterStates.NONEXISTENT,
    )

    (create_cluster >> await_create_cluster >> create_nodegroup >>
     await_create_nodegroup >> start_pod >> delete_nodegroup >>
     await_delete_nodegroup >> delete_cluster >> await_delete_cluster)
    await_create_nodegroup = EKSNodegroupStateSensor(
        task_id='wait_for_create_nodegroup',
        nodegroup_name=NODEGROUP_NAME,
        target_state=NodegroupStates.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_force_delete_cluster]
    # An Amazon EKS cluster can not be deleted with attached resources such as nodegroups or Fargate profiles.
    # Setting the `force` to `True` will delete any attached resources before deleting the cluster.
    delete_all = EKSDeleteClusterOperator(task_id='delete_nodegroup_and_cluster', force_delete_compute=True)
    # [END howto_operator_eks_force_delete_cluster]

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        target_state=ClusterStates.NONEXISTENT,
    )

    create_cluster_and_nodegroup >> await_create_nodegroup >> start_pod >> delete_all >> await_delete_cluster
Beispiel #5
0
    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,
    )

    # An Amazon EKS cluster can not be deleted with attached resources such as nodegroups or Fargate profiles.
    # Setting the `force` to `True` will delete any attached resources before deleting the cluster.
    delete_all = EKSDeleteClusterOperator(
        task_id='delete_fargate_profile_and_cluster',
        force_delete_compute=True)

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        target_state=ClusterStates.NONEXISTENT,
    )

    (create_cluster_and_fargate_profile >> await_create_fargate_profile >>
     start_pod >> delete_all >> await_delete_cluster)
        nodegroup_name=NODEGROUP_NAME,
        target_state=NodegroupStates.ACTIVE,
    )

    start_pod = EKSPodOperator(
        task_id="run_pod",
        cluster_name=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,
    )

    # [START howto_operator_eks_force_delete_cluster]
    # An Amazon EKS cluster can not be deleted with attached resources.
    # Setting the `force` to `True` will delete any attached resources before deleting the cluster.
    delete_all = EKSDeleteClusterOperator(
        task_id='delete_nodegroup_and_cluster', cluster_name=CLUSTER_NAME, force_delete_compute=True
    )
    # [END howto_operator_eks_force_delete_cluster]

    await_delete_cluster = EKSClusterStateSensor(
        task_id='wait_for_delete_cluster',
        cluster_name=CLUSTER_NAME,
        target_state=ClusterStates.NONEXISTENT,
    )

    create_cluster_and_nodegroup >> await_create_nodegroup >> start_pod >> delete_all >> await_delete_cluster