dongzhi4498 2019-03-30 20:38
浏览 355
已采纳

在Kubernetes中运行时,Firebase Admin Go SDK仅获得x509证书错误

I'm currently working on a project using the Firebase Admin Go SDK to handle auth and to use the real time database. The project works correctly when I run it locally (by just running go run main.go). When I run it in Minikube via a docker image (or GKE, I've tested both) I get this error whenever I try to make any Firestore calls:

transport: authentication handshake failed: x509: certificate signed by unknown authority

Here is the code I'm using on the server to make the call to the DB:

// Initialize the app 
opt := option.WithCredentialsFile("./serviceAccountKey.json")
app, err := firebase.NewApp(context.Background(), nil, opt)
// This is the first call I attempt to make, and where the error is thrown
// Create the client
client, err := app.Firestore(context.Background())
iter := client.Collection("remoteModels").Documents(context.Background())
snaps, err := iter.GetAll()
if err != nil {
    logger.Log.Warn("Error getting all remoteModels")
    fmt.Println(err)
    return err
}  

And here is my Dockerfile that adds the service account key Firebase provided me from the console:

FROM scratch

ADD main /
ADD serviceAccountKey.json /

EXPOSE 9090

ENTRYPOINT ["/main", "-grpc-port=9090", "-http-port=9089", "-env=prod"]

I can't find anything in the documentation about running in Kubernetes.
Is there anything I need to do to be able to connect to Firestore from Kubernetes?

  • 写回答

1条回答 默认 最新

  • dousi9215 2019-04-02 05:49
    关注

    If you are using alpine based images try running apk add ca-certificates it looks like a tls error.
    Install ca certificates, it should resolve the issue

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题