kubernetes - 如何在生产环境中配置 Google Storage 密钥文件名
问题描述
对于许多人来说,这可能是一个非常简单的问题,但让我发疯。
我一直在查看谷歌关于通过谷歌存储上传文件的几个文档,并且可以在本地进行 - 但我的问题是我无法让它在 GKE 环境中的生产中工作。
我的上传代码:
let KeyfilenamePath = ''
// if development
keyFilenamePath = path.join(__dirname, '../my-path/keyfile.json');
// if production
keyFilenamePath = ''
const gcBucket = gc.bucket({
keyFilename: keyFilenamePath;
projectId: 'my-project'
});
这在本地环境中运行良好,但我不确定如何通过阅读 Google 的文档使其在生产环境中运行。
我尝试在生产中一起省略 keyFilename,但没有运气。它总是同样的错误:
Error ApiError: Insufficient Permission at new ApiError (/app/node_modules/@google-cloud/common/build/src/util.js:59:15)
现在在我的 pod 上,keyfile.json 显然不存在,而且我还没有设置GOOGLE_APPLICATION_CREDENTIALS
. 但从我收集的信息来看,它仍然可以工作,但我不确定如何让一切都与谷歌的 ADC 合作,如:
https ://cloud.google.com/docs/authentication/production#auth-cloud-implicit-节点
它指出:
If the environment variable isn't set, ADC uses the default service account that Compute Engine, Google Kubernetes Engine, Cloud Run, App Engine, and Cloud Functions provide, for applications that run on those services.
我应该使用 kubernetes 机密设置 json 密钥文件吗? https://jamesdefabia.github.io/docs/user-guide/kubectl/kubectl_create_secret_generic/
我已经搜索了几个小时,不知道如何处理这个问题。
其他资源:
从 Google Cloud Storage 提供 Google 客户服务帐户的 keyFilename
解决方案
推荐阅读
- java - 使用 EventBus 时处理 Vert.x NetSocket writeQueueFull
- javascript - TypeScript 返回不可变/常量/只读数组
- python - Jira POST & PUT Rest 调用从 Python 返回错误 400
- julia - 在 Julia-Lang 中包含文件以考虑更新的正确方法
- c++ - 抛出异常:读取访问冲突。我的代码有什么问题?
- powershell - 根据唯一属性将数组拆分为单独的对象
- c++ - 显示qml时如何在QML中播放声音
- .net - 使用 Serilog 自定义 LogEventLevel
- mysql - PDO Mysql 创建函数并在select中使用
- php - 银条 - CMS - 登录用户名和密码