How to add GOOGLE_APPLICATION_CREDENTIALS env variable to Rancher Server?

I’m trying to add GCE Host to my hosts in Rancher Server. There is google driver available and according to this page it should be possible to configure Application Default Credentials (Service Account)

https://developers.google.com/identity/protocols/application-default-credentials

So, I generated the json file, made it available on the rancher server host and exported the path as GOOGLE_APPLICATION_CREDENTIALS env variable. Still getting this error when trying to add Google Compute Engine Host:

Error with pre-create check: “google: could not find default credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.”

Looks like the GOOGLE_APPLICATION_CREDENTIALS is not read by the ‘Add Host’ functionality. Is there anything else that can be done to make it work?

I have not tested this myself, but did you make the path available inside the Rancher server container?

Sure i forgot to expose the env var to racher container…

After i did it ‘Add Host’ is able to connect to my GCE project and it works for default images and existing hosts. So if i have existing instance running ubuntu rancher is able to initialise itself add this host successfully.
I was not able to make it to create new host because I’m not sure how to specify the reserved IP. Also there is some problem with instance running rancher OS (that i want to use). The process started but stuck in the ‘waiting for ssh to be available’ step for a while and after that something happened so my instance totally disappeared from the Google view… looks like it was deleted by something.

I will stick to creating instances using Google interface/API and adding them as a regular hosts (by IP) to rancher for now, it seems to be working without any extra configuration.

Thanks!
Dmitry