最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

kubernetes - Docker image running in k8s which needs gcloud auth credentials - Stack Overflow

programmeradmin4浏览0评论

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?

Share Improve this question asked Mar 17 at 8:38 khtehkhteh 4,05810 gold badges59 silver badges104 bronze badges 3
  • Are you running this on GKE? If so, can you use workload identity? If not, can you create a service account? – Botje Commented Mar 17 at 8:41
  • No. On a local microk8s cluster. – khteh Commented Mar 17 at 8:44
  • 1 You can 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. – DazWilkin Commented Mar 17 at 15:57
Add a comment  | 

1 Answer 1

Reset to default 2

As 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.

发布评论

评论列表(0)

  1. 暂无评论