Dataproc 上的 Flink 作业 运行 未找到 Google 应用程序默认凭据
Flink job running on Dataproc not finding Google Application Default Credentials
根据大多数文档(不多) 当 运行 在 Google Compute Engine 上安装应用程序时,Google 客户端库应自动获取用于生成 VM 的应用程序默认凭据。
我目前正在 运行在 Dataproc(托管 Hadoop)上安装 Flink 集群。 Dataproc 运行 在 Google Compute Engine 平台上运行,其中包含用于主节点和工作节点的虚拟机。当我使用 Yarn 部署作业时,作业失败,因为它无法检测到应用程序默认凭据。
有谁知道 Flink 是否能够自动获取 VM 上的应用程序默认凭据?我是否需要配置任何东西,或者此功能是否不受支持,我需要在代码中手动指定服务帐户 JSON?
编辑:
更多信息。
Flink 作业是一个流式作业(永无止境),它拾取记录并将它们插入 Google BigQuery table 和 Google 存储桶中。为此,我使用了下面列出的两个客户端库:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.65.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.65.0</version>
</dependency>
我在 Main 运行 函数中添加了一个 GoogleCredentials.getApplicationDefault()
调用以确保正在获取凭据,但这会引发以下错误:
The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials
此外,在日志记录中还有一行 Failed to detect whether we are running on Google Compute Engine
。这让我相信它无法在 Compute Engine 平台中检测到它。
根据一些在线阅读,他们说使用了元数据服务器来检测这一点。我们在 VPC 中 运行ning,所以我认为它无法建立连接。确实如此吗?如果是这样,我可以使用另一种方法吗?
所以这可能并不适合所有人,但问题出在设置中。
我正在使用 Kubernetes pod 启动 Yarn 会话并使用它将作业提交到 Flink 集群。如果 运行 使用这种方法,需要记住的是,拓扑似乎是 运行 在任务管理器上,并且主要功能正在启动 Yarn 会话的机器上调用。就我而言,这是吊舱。
将服务帐户凭据安装到 pod 并指定 GOOGLE_APPLICATION_CREDENTIALS
指向该目录解决了这个问题。
根据大多数文档(不多) 当 运行 在 Google Compute Engine 上安装应用程序时,Google 客户端库应自动获取用于生成 VM 的应用程序默认凭据。
我目前正在 运行在 Dataproc(托管 Hadoop)上安装 Flink 集群。 Dataproc 运行 在 Google Compute Engine 平台上运行,其中包含用于主节点和工作节点的虚拟机。当我使用 Yarn 部署作业时,作业失败,因为它无法检测到应用程序默认凭据。
有谁知道 Flink 是否能够自动获取 VM 上的应用程序默认凭据?我是否需要配置任何东西,或者此功能是否不受支持,我需要在代码中手动指定服务帐户 JSON?
编辑:
更多信息。
Flink 作业是一个流式作业(永无止境),它拾取记录并将它们插入 Google BigQuery table 和 Google 存储桶中。为此,我使用了下面列出的两个客户端库:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.65.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.65.0</version>
</dependency>
我在 Main 运行 函数中添加了一个 GoogleCredentials.getApplicationDefault()
调用以确保正在获取凭据,但这会引发以下错误:
The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials
此外,在日志记录中还有一行 Failed to detect whether we are running on Google Compute Engine
。这让我相信它无法在 Compute Engine 平台中检测到它。
根据一些在线阅读,他们说使用了元数据服务器来检测这一点。我们在 VPC 中 运行ning,所以我认为它无法建立连接。确实如此吗?如果是这样,我可以使用另一种方法吗?
所以这可能并不适合所有人,但问题出在设置中。
我正在使用 Kubernetes pod 启动 Yarn 会话并使用它将作业提交到 Flink 集群。如果 运行 使用这种方法,需要记住的是,拓扑似乎是 运行 在任务管理器上,并且主要功能正在启动 Yarn 会话的机器上调用。就我而言,这是吊舱。
将服务帐户凭据安装到 pod 并指定 GOOGLE_APPLICATION_CREDENTIALS
指向该目录解决了这个问题。