繁体   English   中英

Spring 启动云 SQL 与 Kubernetes 引擎 GKE Google Cloud

[英]Spring boot Cloud SQL with Kubernetes engine GKE Google Cloud

我创建了一个与 Cloud SQL(MySQL) 连接的 spring 引导项目。 我已经在谷歌云(cloudrun)中部署了它,它正在其中工作。

现在,我正在尝试在 kubernates enigne GKE 中部署 spring 启动应用程序的相同容器映像,我希望这将与 mysql 云 sql 实例连接但是,我在应用程序 POD 日志中遇到错误。


     "method" : "google.cloud.sql.v1beta4.SqlInstancesService.CreateEphemeral"
      "service" : "sqladmin.googleapis.com",
    "metadata" : {
    "domain" : "googleapis.com",
    "reason" : "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
    "@type" : "type.googleapis.com/google.rpc.ErrorInfo",
  "details" : [ {
  "status" : "PERMISSION_DENIED",
  "message" : "Request had insufficient authentication scopes.",
  } ],
    "reason" : "insufficientPermissions"
    "message" : "Insufficient Permission",
    "domain" : "global",
  "errors" : [ {
  "code" : 403,

Failed to create ephemeral certificate for the Cloud SQL instance.

请帮助解决这个问题......可能是什么解决方案

不确定如何传递服务帐户文件,但您可以使用Kubernetes密钥传递它,或者使用服务帐户并将其附加到部署中。

kubectl create secret generic google-application-credentials --from-file=./application-credentials.json

附加秘密的部署卷

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

在路径上挂载秘密

spec:
  containers:
  - name: my-service
    volumeMounts:
    - name: google-application-credentials-volume
      mountPath: /etc/gcp
      readOnly: true

最后,您可以传递指向该文件的环境变量和 cred

spec:
  containers:
  - name: my-service
    env:
    - name: GOOGLE_APPLICATION_CREDENTIALS
      value: /etc/gcp/application-credentials.json

确保您的服务帐户具有足够的角色来更新 Cloud SQL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM