Application Default Credentials not available

10/25/2017

I have some Java applications running on Google Compute Engine instances in a Container Engine cluster. I upgraded the cluster to newest version (1.7.8) and changed the node images from the container optimised OS to Ubuntu. Now my pods are crashing when trying to connect to the cloud sql database with this error message:

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.

The service account is the same as before the upgrade with the scope https://www.googleapis.com/auth/sqlservice.admin

Does anyone have an idea why I'm getting this error now? Is the best solution is to create the environment variable?

-- linemos
gcloud
google-compute-engine
google-kubernetes-engine
java

1 Answer

1/2/2018

Ideally you should be using GOOGLE_APPLICATION_CREDENTIALS environment variable. Otherwise you are using the "Compute Engine default service account" of the VMs.

See this tutorial for the best practices: https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform

-- AhmetB - Google
Source: StackOverflow