Skip to content

Add support for impersonation in GKEStartPodOperator, DataflowCreateJavaJobOperator and DataflowCreatePythonJobOperator #10596

Closed

Description

@olchas

Description

GKEStartPodOperator, DataflowCreateJavaJobOperator and DataflowCreatePythonJobOperator do not support direct impersonation of a service account in Google services.

Use case / motivation

GKEStartPodOperator, DataflowCreateJavaJobOperator and DataflowCreatePythonJobOperator, in contrary to other Google operators, do not use Credentials class for authentication, so they require individual approach to support direct impersonation in them.

In case of GKEStartPodOperator it seems it should suffice to add --impersonate-service-account to the gcloud container clusters get-credentials command. However, this way we will not be able to use chain of service accounts, like in the rest of Google operators.

In case of DataflowCreateJavaJobOperator and DataflowCreatePythonJobOperator, some changes in provide_gcp_credential_file_as_context will probably be needed.

Related Issues

#8803

Activity

  1. rajatsri28 commented on Oct 5, 2020

    @rajatsri28
    Contributor

    Hi @olchas ,
    Can I pick this up?

  2. mik-laj commented on Oct 5, 2020

    @mik-laj
    Member

    @rajatsri28 Do you have experience with Google Cloud? This task is trivial from an Airflow perspective, but requires above-average knowledge of the Google Cloud platform. I don't want you to have a bad experience after contributing to this project.

  3. rajatsri28 commented on Oct 5, 2020

    @rajatsri28
    Contributor

    Hi @mik-laj , Yes I have some experience with Google Cloud. At Twitter, we migrated from on-premise offering to provide Airflow on GKE (GCP) so I can somewhat relate to this issue as well.

  4. mik-laj commented on Oct 5, 2020

    @mik-laj
    Member

    @rajatsri28 Awesome! I assigned you to this ticket. 🐈

  5. rajatsri28 commented on Oct 15, 2020

    @rajatsri28
    Contributor

    Hi,
    For GKEStartPodOperator, I did not find any way to use a chain of service accounts for impersonation. It seems it's only available via the API. So I am thinking of following what is suggested here, i.e. to add --impersonate-service-account to the gcloud container clusters get-credentials command.

    For DataflowCreateJavaJobOperator and DataflowCreatePythonJobOperator, I am a bit confused since there are not many options to update ADC. Are we looking for something like running gcloud config set auth/impersonate_service_account command to declare the impersonation? However, we will not be able to specify a chain of accounts then.

  6. mik-laj commented on Oct 19, 2020

    @mik-laj
    Member

    @rajatsri28 I think support for a single service account is sufficient in most cases. gcloud config set auth/impersonate_service_account The gcloud command should work for all operators that use gcloud, so all you have to do is add account name forwarding in airflow.providers.google.common.hooks.base_google.GoogleBaseHook.provide_authorized_gcloud method.

    gcloud config set auth/impersonate_service_account command and --impersonate-service-account argument behave similarly, but I think the first method will be simpler to implement. I am not sure about this and think it is worth checking for all the gcloud supported authentication methods.

  7. abhishekbafna commented on Aug 27, 2021

    @abhishekbafna
    Contributor

    The DataflowCreateJavaJobOperator is documented as deprecated and users are suggested to use the BeamRunJavaPipelineOperator. I tried that and I believe, I was not able to impersonate the different service account in that as well. The reason could be that the underline logic might be the same between the two operators. We should add these Beam operators also into the above list.

  8. shahar1 commented on Jan 31, 2023

    @shahar1
    Contributor

    @eladkal Please assign me

  9. removed their assignment
    on Feb 10, 2023
  10. shahar1 commented on Feb 11, 2023

    @shahar1
    Contributor

    @eladkal Please reassign, I unassigned by accident

  11. shahar1 commented on Mar 3, 2023

    @shahar1
    Contributor

    I've been trying to resolve this issue, and it seems that:

    Therefore, this issue could be closed as it is already resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions