Ami*_*Pal 4 docker google-cloud-platform kubernetes google-kubernetes-engine
Firebase我在GoLang托管的项目中使用Google Kubernetes Engine.
我遵循的步骤:
在 firebase 帐户上启用 firebase admin SDK。JSON它为我生成了一个服务帐户。这还在我的 Google 控制台服务凭证下创建了一个服务帐户。
按照这个答案并使用添加新的密钥kubectl create secret generic google-application-credentials --from-file=./sample-project.json
对我的文件进行了更改deployment.YAML(添加了卷安装和环境变量)
spec:
containers:
- image: gcr.io/sample-ee458/city:0.27
name: city-app
volumeMounts:
- name: google-application-credentials-volume
mountPath: /etc/gcp
readOnly: true
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /etc/gcp/application-credentials.json
Run Code Online (Sandbox Code Playgroud)
在同一文件中设置音量
volumes:
- name: google-application-credentials-volume
secret:
secretName: google-application-credentials
items:
- key: application-credentials.json # default name created by the create secret from-file command
path: application-credentials.json
Run Code Online (Sandbox Code Playgroud)
使用命令运行kubectl apply -f deployment.yaml和部署docker push。
它把我扔了error getting credentials using google_application_credentials environment variable gke。我在这里缺少什么?任何提示都会很明显。
最后,我弄清楚如何复制它并使用环境变量。这是。更新后的YAML文件
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: my-app
spec:
template:
spec:
volumes:
- name: google-cloud-keys
secret:
secretName: gac-keys
containers:
- name: my-app
image: us.gcr.io/my-app
volumeMounts:
- name: google-cloud-keys
mountPath: /var/secrets/google
readOnly: true
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /var/secrets/google/new-file-name.json
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8786 次 |
| 最近记录: |