I need run a python app in docker container on k8s. This app needs to use gcloud stuff like gemini-2.0-flash
, google_vertexai
and
vertexai.init(project=os.environ.get("GOOGLE_CLOUD_PROJECT"), location=os.environ.get("GOOGLE_CLOUD_LOCATION"))
I can install the gcloud
CLI in Dockerfile. What's next after that? Any reference?
I need run a python app in docker container on k8s. This app needs to use gcloud stuff like gemini-2.0-flash
, google_vertexai
and
vertexai.init(project=os.environ.get("GOOGLE_CLOUD_PROJECT"), location=os.environ.get("GOOGLE_CLOUD_LOCATION"))
I can install the gcloud
CLI in Dockerfile. What's next after that? Any reference?
1 Answer
Reset to default 2As commented by @DazWilkin, your issue could be resolved if you leverage the instructions to use ADC for local development. Using your user credentials (Google Account) or impersonating a Service Account will create a key (on Linux in ${HOME}/.config/gcloud/application_default_credentials.json
) that you can (volume) mount into the container, then reference using the environment variable GOOGLE_APPLICATION_CREDENTIALS
. You need only have gcloud installed on the host not the container.
Posting the answer as community wiki for the benefit of the community that might encounter this use case in the future. Feel free to edit this answer for additional information.
${HOME}/.config/gcloud/application_default_credentials.json
) that you can (volume) mount into the container, then reference using the environment variableGOOGLE_APPLICATION_CREDENTIALS
. You need only havegcloud
installed on the host not the container. – DazWilkin Commented Mar 17 at 15:57