应用程序默认凭据不可用

问题描述 投票:2回答:1

我在Container Engine集群中的Google Compute Engine实例上运行了一些Java应用程序。我将集群升级到最新版本(1.7.8)并将节点映像从容器优化操作系统更改为Ubuntu。现在我的pod在尝试使用此错误消息连接到云sql数据库时崩溃:

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.
See https://developers.google.com/accounts/docs/application-default-credentials for more information.

服务帐户与使用范围https://www.googleapis.com/auth/sqlservice.admin进行升级之前的帐户相同

有谁知道为什么我现在收到这个错误?最好的解决方案是创建环境变量吗?

java google-compute-engine gcloud google-kubernetes-engine
1个回答
0
投票

理想情况下,您应该使用GOOGLE_APPLICATION_CREDENTIALS环境变量。否则,您正在使用VM的“计算引擎默认服务帐户”。

有关最佳实践,请参阅本教程:https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform

© www.soinside.com 2019 - 2024. All rights reserved.