Java 应用程序默认凭据不可用

Java 应用程序默认凭据不可用,java,google-compute-engine,gcloud,google-kubernetes-engine,Java,Google Compute Engine,Gcloud,Google Kubernetes Engine,我有一些Java应用程序在容器引擎集群中的Google计算引擎实例上运行。我将集群升级到最新版本(1.7.8),并将节点映像从容器优化操作系统更改为Ubuntu。现在,我的POD在尝试连接到云sql数据库时崩溃,并显示以下错误消息: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environ

我有一些Java应用程序在容器引擎集群中的Google计算引擎实例上运行。我将集群升级到最新版本(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


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

理想情况下,您应该使用
GOOGLE\u APPLICATION\u CREDENTIALS
环境变量。否则,您将使用虚拟机的“计算引擎默认服务帐户”

有关最佳实践,请参见本教程: