Skip to content

[AIRFLOW-6290] Create guide for GKE operators #8883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

tanjinP
Copy link
Contributor

@tanjinP tanjinP commented May 16, 2020

Closes AIRFLOW-6290 / issue #8206 .

Contains a guide that is appropriately linked to on how to use the various operators in GKE Service.


Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@boring-cyborg boring-cyborg bot added area:docs provider:google Google (including GCP) related issues labels May 16, 2020
* `GKE API Documentation <https://cloud.google.com/kubernetes-engine/docs/reference/rest>`__
* `Product Documentation <https://cloud.google.com/kubernetes-engine/docs/>`__
* `Kubernetes Documentation <https://kubernetes.io/docs/home/>`__
* `Kubernetes Documentation <https://kubernetes.io/docs/home/>`__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `Kubernetes Documentation <https://kubernetes.io/docs/home/>`__

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


.. _howto/operator:GKEStartPodOperator:

Run a Pod on a GKE cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is a duplicate of this

Specified guide as part of addressing that comment so considering this done.

Comment on lines 93 to 98
To run a Kubernetes Pod on a GKE cluster, use
:class:`~airflow.providers.google.cloud.operators.kubernetes_engine.GKEStartPodOperator`.
It is worth noting that this extends
:class:`~airflow.providers.cncf.kubernetes.operators.kubernetes_pod.KubernetesPodOperator`
so many of the same arguments can be used. We can enable the usage of :ref:`XCom <concepts:xcom>`
on the operator:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To run a Kubernetes Pod on a GKE cluster, use
:class:`~airflow.providers.google.cloud.operators.kubernetes_engine.GKEStartPodOperator`.
It is worth noting that this extends
:class:`~airflow.providers.cncf.kubernetes.operators.kubernetes_pod.KubernetesPodOperator`
so many of the same arguments can be used. We can enable the usage of :ref:`XCom <concepts:xcom>`
on the operator:
You can use two operators to run pod on a GKE cluster:
* :class:`~airflow.providers.cncf.kubernetes.operators.kubernetes_pod.KubernetesPodOperator`
* :class:`~airflow.providers.google.cloud.operators.kubernetes_engine.GKEStartPodOperator`
``GKEPodOperator`` extends ``KubernetesPodOperator`` to provide authorization using a Google credentials. This way you don't have to manage the `kube_config` file, but it will be generated automatically. All Kubernetes (except `config_file`) parameters are also valid for GKEStartPodOperator.
For more information about starting pods on Airflow, please look at: :ref:`howto/operator:KubernetesPodOperator` guide.
We can enable the usage of :ref:`XCom <concepts:xcom>` on the operator:

WDYT? I would like to show a clear difference between these two operators, because it can be embarrassing. GKEPodOperator is not magic operaotr. It's only wrapper.

This is especially important for me because this information is not in the Cloud Composer documentation, and I often redirect users to this documentation if they want to use KubernetesPodOperator
https://cloud.google.com/composer/docs/how-to/using/using-kubernetes-pod-operator
This guide is in the Cloud Composer documentation but applies to all users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.




Google Kubernetes Engine Operators
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add link to this guide in the Kubernetes Pod Operator guide?
https://airflow.readthedocs.io/en/latest/howto/operator/kubernetes.html

    .. note::
        If you use `Google Kubernetes Engine <https://cloud.google.com/kubernetes-engine/>`__, use
        :ref:`GKEStartPodOperator <howto/operator:GKEStartPodOperator>`__ operaator, which
        simplifies the authorization process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so many of the same arguments can be used. We can enable the usage of :ref:`XCom <concepts:xcom>`
on the operator:

.. exampleinclude:: ../../../../airflow/providers/google/cloud/example_dags/example_kubernetes_engine.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write a long description about data transfer via xcom? I am missing information about the /airflow/xcom/return.json file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tanjinP tanjinP requested a review from mik-laj May 20, 2020 04:38
@tanjinP tanjinP force-pushed the airflow-6290-create-guide-for-gke-operators branch from 025aa4c to 9b7ceb8 Compare May 31, 2020 01:29
@mik-laj
Copy link
Member

mik-laj commented May 31, 2020

@tanjinP It looks good. Should I merge it?

@tanjinP
Copy link
Contributor Author

tanjinP commented Jun 3, 2020

@mik-laj - I'm good for the merge, thanks for checking in!
:shipit:

@mik-laj
Copy link
Member

mik-laj commented Jun 3, 2020

@tanjinP Static checks are sad. Can you fix it?

@mik-laj
Copy link
Member

mik-laj commented Jun 3, 2020

Github Action are sad. Can you fix it?

@tanjinP tanjinP force-pushed the airflow-6290-create-guide-for-gke-operators branch from 1526ead to 7f26469 Compare June 5, 2020 02:30
@tanjinP
Copy link
Contributor Author

tanjinP commented Jun 5, 2020

Github Action are sad. Can you fix it?

All checks are happy again.

Sorry for the strange number of commits, it looks like I screwed up with the rebasing. However I don't think it matters for now as long as we squash them into master which I believe is always done. In any case it looks good to merge 👍

@mik-laj mik-laj merged commit f56811d into apache:master Jun 5, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 5, 2020

Awesome work, congrats on your first merged pull request!

@mik-laj
Copy link
Member

mik-laj commented Jun 5, 2020

Thanks for the great contributions. What is your next step?

@tanjinP
Copy link
Contributor Author

tanjinP commented Jun 5, 2020

Thanks for the great contributions. What is your next step?

Thank you for the help! There are still a few other issues/PRs I'm working through so I will continue working on them.

@tanjinP tanjinP deleted the airflow-6290-create-guide-for-gke-operators branch June 5, 2020 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants